mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-02-20 18:01:33 +00:00
NotesService: Fix type errors
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
e217b30d26
commit
772263317d
1 changed files with 14 additions and 10 deletions
|
@ -102,7 +102,8 @@ export class NotesService {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return await this.noteRepository.save(newNote);
|
return await this.noteRepository.save(newNote);
|
||||||
} catch {
|
} catch (e) {
|
||||||
|
if (alias) {
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
`A note with the alias '${alias}' already exists.`,
|
`A note with the alias '${alias}' already exists.`,
|
||||||
'createNote',
|
'createNote',
|
||||||
|
@ -110,6 +111,9 @@ export class NotesService {
|
||||||
throw new AlreadyInDBError(
|
throw new AlreadyInDBError(
|
||||||
`A note with the alias '${alias}' already exists.`,
|
`A note with the alias '${alias}' already exists.`,
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +308,7 @@ export class NotesService {
|
||||||
* @param {Note} note - the note to use
|
* @param {Note} note - the note to use
|
||||||
* @return {User} user to be used as updateUser in the NoteDto
|
* @return {User} user to be used as updateUser in the NoteDto
|
||||||
*/
|
*/
|
||||||
async calculateUpdateUser(note: Note): Promise<User> {
|
async calculateUpdateUser(note: Note): Promise<User | null> {
|
||||||
const lastRevision = await this.getLatestRevision(note);
|
const lastRevision = await this.getLatestRevision(note);
|
||||||
if (lastRevision && lastRevision.authorships) {
|
if (lastRevision && lastRevision.authorships) {
|
||||||
// Sort the last Revisions Authorships by their updatedAt Date to get the latest one
|
// Sort the last Revisions Authorships by their updatedAt Date to get the latest one
|
||||||
|
@ -333,7 +337,7 @@ export class NotesService {
|
||||||
*/
|
*/
|
||||||
toNotePermissionsDto(note: Note): NotePermissionsDto {
|
toNotePermissionsDto(note: Note): NotePermissionsDto {
|
||||||
return {
|
return {
|
||||||
owner: this.usersService.toUserDto(note.owner),
|
owner: note.owner ? this.usersService.toUserDto(note.owner) : undefined,
|
||||||
sharedToUsers: note.userPermissions.map((noteUserPermission) => ({
|
sharedToUsers: note.userPermissions.map((noteUserPermission) => ({
|
||||||
user: this.usersService.toUserDto(noteUserPermission.user),
|
user: this.usersService.toUserDto(noteUserPermission.user),
|
||||||
canEdit: noteUserPermission.canEdit,
|
canEdit: noteUserPermission.canEdit,
|
||||||
|
|
Loading…
Reference in a new issue