NotesService.toNoteMetadataDto: Handle undefined updateUser

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-04-29 18:30:48 +02:00
parent f8efb9717e
commit f9a0353748
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

View file

@ -356,10 +356,11 @@ export class NotesService {
* @return {NoteMetadataDto} the built NoteMetadataDto
*/
async toNoteMetadataDto(note: Note): Promise<NoteMetadataDto> {
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,
};
}