mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-24 18:56:32 -05:00
Add more features to NotesService
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
0d4c489aa5
commit
4cd574306e
1 changed files with 160 additions and 1 deletions
|
@ -1,5 +1,10 @@
|
|||
import { Injectable, Logger } from "@nestjs/common";
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { NoteMetadataDto } from './note-metadata.dto';
|
||||
import {
|
||||
NotePermissionsDto,
|
||||
NotePermissionsUpdateDto,
|
||||
} from './note-permissions.dto';
|
||||
import { NoteDto } from './note.dto';
|
||||
|
||||
@Injectable()
|
||||
export class NotesService {
|
||||
|
@ -36,4 +41,158 @@ export class NotesService {
|
|||
},
|
||||
];
|
||||
}
|
||||
|
||||
createNote(noteContent: string, alias?: NoteMetadataDto['alias']): NoteDto {
|
||||
this.logger.warn('Using hardcoded data!');
|
||||
return {
|
||||
content: noteContent,
|
||||
metdata: {
|
||||
alias: alias,
|
||||
createTime: new Date(),
|
||||
description: 'Very descriptive text.',
|
||||
editedBy: [],
|
||||
id: 'foobar-barfoo',
|
||||
permission: {
|
||||
owner: {
|
||||
displayName: 'foo',
|
||||
userName: 'fooUser',
|
||||
email: 'foo@example.com',
|
||||
photo: '',
|
||||
},
|
||||
sharedTo: [],
|
||||
},
|
||||
tags: [],
|
||||
title: 'Title!',
|
||||
updateTime: new Date(),
|
||||
updateUser: {
|
||||
displayName: 'foo',
|
||||
userName: 'fooUser',
|
||||
email: 'foo@example.com',
|
||||
photo: '',
|
||||
},
|
||||
viewCount: 42,
|
||||
},
|
||||
editedByAtPosition: [],
|
||||
};
|
||||
}
|
||||
|
||||
getNoteByIdOrAlias(noteIdOrAlias: string) {
|
||||
this.logger.warn('Using hardcoded data!');
|
||||
return {
|
||||
content: 'noteContent',
|
||||
metdata: {
|
||||
alias: null,
|
||||
createTime: new Date(),
|
||||
description: 'Very descriptive text.',
|
||||
editedBy: [],
|
||||
id: noteIdOrAlias,
|
||||
permission: {
|
||||
owner: {
|
||||
displayName: 'foo',
|
||||
userName: 'fooUser',
|
||||
email: 'foo@example.com',
|
||||
photo: '',
|
||||
},
|
||||
sharedTo: [],
|
||||
},
|
||||
tags: [],
|
||||
title: 'Title!',
|
||||
updateTime: new Date(),
|
||||
updateUser: {
|
||||
displayName: 'foo',
|
||||
userName: 'fooUser',
|
||||
email: 'foo@example.com',
|
||||
photo: '',
|
||||
},
|
||||
viewCount: 42,
|
||||
},
|
||||
editedByAtPosition: [],
|
||||
};
|
||||
}
|
||||
|
||||
deleteNoteByIdOrAlias(noteIdOrAlias: string) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateNoteByIdOrAlias(noteIdOrAlias: string, noteContent: string) {
|
||||
this.logger.warn('Using hardcoded data!');
|
||||
return {
|
||||
content: noteContent,
|
||||
metdata: {
|
||||
alias: null,
|
||||
createTime: new Date(),
|
||||
description: 'Very descriptive text.',
|
||||
editedBy: [],
|
||||
id: noteIdOrAlias,
|
||||
permission: {
|
||||
owner: {
|
||||
displayName: 'foo',
|
||||
userName: 'fooUser',
|
||||
email: 'foo@example.com',
|
||||
photo: '',
|
||||
},
|
||||
sharedTo: [],
|
||||
},
|
||||
tags: [],
|
||||
title: 'Title!',
|
||||
updateTime: new Date(),
|
||||
updateUser: {
|
||||
displayName: 'foo',
|
||||
userName: 'fooUser',
|
||||
email: 'foo@example.com',
|
||||
photo: '',
|
||||
},
|
||||
viewCount: 42,
|
||||
},
|
||||
editedByAtPosition: [],
|
||||
};
|
||||
}
|
||||
|
||||
getNoteMetadata(noteIdOrAlias: string): NoteMetadataDto {
|
||||
return {
|
||||
alias: null,
|
||||
createTime: new Date(),
|
||||
description: 'Very descriptive text.',
|
||||
editedBy: [],
|
||||
id: noteIdOrAlias,
|
||||
permission: {
|
||||
owner: {
|
||||
displayName: 'foo',
|
||||
userName: 'fooUser',
|
||||
email: 'foo@example.com',
|
||||
photo: '',
|
||||
},
|
||||
sharedTo: [],
|
||||
},
|
||||
tags: [],
|
||||
title: 'Title!',
|
||||
updateTime: new Date(),
|
||||
updateUser: {
|
||||
displayName: 'foo',
|
||||
userName: 'fooUser',
|
||||
email: 'foo@example.com',
|
||||
photo: '',
|
||||
},
|
||||
viewCount: 42,
|
||||
};
|
||||
}
|
||||
|
||||
updateNotePermissions(
|
||||
noteIdOrAlias: string,
|
||||
newPermissions: NotePermissionsUpdateDto,
|
||||
): NotePermissionsDto {
|
||||
return {
|
||||
owner: {
|
||||
displayName: 'foo',
|
||||
userName: 'fooUser',
|
||||
email: 'foo@example.com',
|
||||
photo: '',
|
||||
},
|
||||
sharedTo: [],
|
||||
};
|
||||
}
|
||||
|
||||
getNoteContent(noteIdOrAlias: string) {
|
||||
return '# Markdown';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue