mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 14:44:43 -04:00
NotesService: Use the database for delete and update actions.
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
05f25b92aa
commit
cf88cde551
1 changed files with 10 additions and 36 deletions
|
@ -145,44 +145,18 @@ export class NotesService {
|
||||||
return this.toNoteDto(note);
|
return this.toNoteDto(note);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteNoteByIdOrAlias(noteIdOrAlias: string) {
|
async deleteNoteByIdOrAlias(noteIdOrAlias: string) {
|
||||||
this.logger.warn('Using hardcoded data!');
|
const note = await this.getNoteByIdOrAlias(noteIdOrAlias);
|
||||||
return;
|
return await this.noteRepository.remove(note);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNoteByIdOrAlias(noteIdOrAlias: string, noteContent: string) {
|
async updateNoteByIdOrAlias(noteIdOrAlias: string, noteContent: string) {
|
||||||
this.logger.warn('Using hardcoded data!');
|
const note = await this.getNoteByIdOrAlias(noteIdOrAlias);
|
||||||
return {
|
const revisions = await note.revisions;
|
||||||
content: noteContent,
|
//TODO: Calculate patch
|
||||||
metdata: {
|
revisions.push(Revision.create(noteContent, noteContent));
|
||||||
alias: null,
|
note.revisions = Promise.resolve(revisions);
|
||||||
createTime: new Date(),
|
await this.noteRepository.save(note);
|
||||||
description: 'Very descriptive text.',
|
|
||||||
editedBy: [],
|
|
||||||
id: noteIdOrAlias,
|
|
||||||
permission: {
|
|
||||||
owner: {
|
|
||||||
displayName: 'foo',
|
|
||||||
userName: 'fooUser',
|
|
||||||
email: 'foo@example.com',
|
|
||||||
photo: '',
|
|
||||||
},
|
|
||||||
sharedToUsers: [],
|
|
||||||
sharedToGroups: [],
|
|
||||||
},
|
|
||||||
tags: [],
|
|
||||||
title: 'Title!',
|
|
||||||
updateTime: new Date(),
|
|
||||||
updateUser: {
|
|
||||||
displayName: 'foo',
|
|
||||||
userName: 'fooUser',
|
|
||||||
email: 'foo@example.com',
|
|
||||||
photo: '',
|
|
||||||
},
|
|
||||||
viewCount: 42,
|
|
||||||
},
|
|
||||||
editedByAtPosition: [],
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getNoteMetadata(noteIdOrAlias: string): NoteMetadataDto {
|
getNoteMetadata(noteIdOrAlias: string): NoteMetadataDto {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue