History: Add history service and usage

Add history service to allow for CRUD operations.
Use history service in controllers to:
  1. Allow manipulating of history entries
  2. Guaranty the correct existence of history entries

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2021-02-03 21:22:55 +01:00
parent b76fa91a3c
commit 7f1afc30c9
8 changed files with 173 additions and 118 deletions

View file

@ -177,6 +177,10 @@ export class NotesService {
return this.getCurrentContent(note);
}
toTagList(note: Note): string[] {
return note.tags.map((tag) => tag.name);
}
async toNotePermissionsDto(note: Note): Promise<NotePermissionsDto> {
return {
owner: this.usersService.toUserDto(note.owner),
@ -204,7 +208,7 @@ export class NotesService {
),
// TODO: Extract into method
permissions: await this.toNotePermissionsDto(note),
tags: note.tags.map((tag) => tag.name),
tags: this.toTagList(note),
updateTime: (await this.getLatestRevision(note)).createdAt,
// TODO: Get actual updateUser
updateUser: {