diff --git a/src/notes/note-metadata.dto.ts b/src/notes/note-metadata.dto.ts index f23972eec..f28621340 100644 --- a/src/notes/note-metadata.dto.ts +++ b/src/notes/note-metadata.dto.ts @@ -31,7 +31,7 @@ export class NoteMetadataDto { @IsString() @IsOptional() @ApiPropertyOptional() - alias?: string; + alias: string | null; /** * Title of the note @@ -74,7 +74,7 @@ export class NoteMetadataDto { @ValidateNested() @ApiPropertyOptional({ type: UserInfoDto }) @IsOptional() - updateUser?: UserInfoDto; + updateUser: UserInfoDto | null; /** * Counts how many times the published note has been viewed diff --git a/src/notes/note-permissions.dto.ts b/src/notes/note-permissions.dto.ts index 829732ee3..a9a0d9389 100644 --- a/src/notes/note-permissions.dto.ts +++ b/src/notes/note-permissions.dto.ts @@ -92,7 +92,7 @@ export class NotePermissionsDto { @ValidateNested() @ApiPropertyOptional({ type: UserInfoDto }) @IsOptional() - owner?: UserInfoDto; + owner: UserInfoDto | null; /** * List of users the note is shared with diff --git a/src/notes/notes.service.ts b/src/notes/notes.service.ts index 6500682ac..481700186 100644 --- a/src/notes/notes.service.ts +++ b/src/notes/notes.service.ts @@ -337,7 +337,7 @@ export class NotesService { */ toNotePermissionsDto(note: Note): NotePermissionsDto { return { - owner: note.owner ? this.usersService.toUserDto(note.owner) : undefined, + owner: note.owner ? this.usersService.toUserDto(note.owner) : null, sharedToUsers: note.userPermissions.map((noteUserPermission) => ({ user: this.usersService.toUserDto(noteUserPermission.user), canEdit: noteUserPermission.canEdit, @@ -360,7 +360,7 @@ export class NotesService { return { // TODO: Convert DB UUID to base64 id: note.id, - alias: note.alias ?? undefined, + alias: note.alias ?? null, title: note.title ?? '', createTime: (await this.getFirstRevision(note)).createdAt, description: note.description ?? '', @@ -370,9 +370,7 @@ export class NotesService { permissions: this.toNotePermissionsDto(note), tags: this.toTagList(note), updateTime: (await this.getLatestRevision(note)).createdAt, - updateUser: updateUser - ? this.usersService.toUserDto(updateUser) - : undefined, + updateUser: updateUser ? this.usersService.toUserDto(updateUser) : null, viewCount: note.viewCount, }; }