NotesService: Rename getCurrentContent to getNoteContentByNote

The new name should better explain what this functions does.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2021-02-19 13:36:01 +01:00 committed by David Mehren
parent 1df4039b79
commit aa97a87316
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
3 changed files with 16 additions and 7 deletions

View file

@ -74,10 +74,19 @@ export class NotesService {
newNote.historyEntries = [HistoryEntry.create(owner)];
newNote.owner = owner;
}
return this.noteRepository.save(newNote);
try {
return await this.noteRepository.save(newNote);
} catch {
this.logger.debug(
`A note with the alias '${alias}' already exists.`,
'createNote',
);
throw new AlreadyInDBError(
`A note with the alias '${alias}' already exists.`,
);
}
}
async getCurrentContent(note: Note): Promise<string> {
async getNoteContentByNote(note: Note): Promise<string> {
return (await this.getLatestRevision(note)).content;
}