From f9a035374888d3d39b6d16fe6cadb7d9c08ea947 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Thu, 29 Apr 2021 18:30:48 +0200 Subject: [PATCH] NotesService.toNoteMetadataDto: Handle undefined updateUser Signed-off-by: David Mehren --- src/notes/notes.service.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/notes/notes.service.ts b/src/notes/notes.service.ts index 865d6978f..6500682ac 100644 --- a/src/notes/notes.service.ts +++ b/src/notes/notes.service.ts @@ -356,10 +356,11 @@ export class NotesService { * @return {NoteMetadataDto} the built NoteMetadataDto */ async toNoteMetadataDto(note: Note): Promise { + const updateUser = await this.calculateUpdateUser(note); return { // TODO: Convert DB UUID to base64 id: note.id, - alias: note.alias, + alias: note.alias ?? undefined, title: note.title ?? '', createTime: (await this.getFirstRevision(note)).createdAt, description: note.description ?? '', @@ -369,9 +370,9 @@ export class NotesService { permissions: this.toNotePermissionsDto(note), tags: this.toTagList(note), updateTime: (await this.getLatestRevision(note)).createdAt, - updateUser: this.usersService.toUserDto( - await this.calculateUpdateUser(note), - ), + updateUser: updateUser + ? this.usersService.toUserDto(updateUser) + : undefined, viewCount: note.viewCount, }; }