HistoryService: Refactor deleteHistoryEntry

The function now expects a `Note` object instead of a noteId to
make it more consistent with other functions.

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-08-29 21:42:46 +02:00
parent c515569299
commit b552fc10b6
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
6 changed files with 13 additions and 13 deletions

View file

@ -107,11 +107,13 @@ export class HistoryController {
}
@Delete(':note')
async deleteHistoryEntry(@Param('note') noteId: string): Promise<void> {
async deleteHistoryEntry(
@Param('note', GetNotePipe) note: Note,
): Promise<void> {
try {
// ToDo: use actual user here
const user = await this.userService.getUserByUsername('hardcoded');
await this.historyService.deleteHistoryEntry(noteId, user);
await this.historyService.deleteHistoryEntry(note, user);
} catch (e) {
if (e instanceof NotInDBError) {
throw new NotFoundException(e.message);

View file

@ -149,7 +149,7 @@ export class MeController {
@ApiNotFoundResponse({ description: notFoundDescription })
async deleteHistoryEntry(
@RequestUser() user: User,
@Param('note') note: string,
@Param('note', GetNotePipe) note: Note,
): Promise<void> {
// ToDo: Check if user is allowed to delete note
try {