diff --git a/src/api/public/me/me.controller.ts b/src/api/public/me/me.controller.ts index 1169820ea..1b9e73b5f 100644 --- a/src/api/public/me/me.controller.ts +++ b/src/api/public/me/me.controller.ts @@ -59,6 +59,26 @@ export class MeController { ); } + @UseGuards(TokenAuthGuard) + @Get('history/:note') + async getHistoryEntry( + @Req() req: Request, + @Param('note') note: string, + ): Promise { + try { + const foundEntry = await this.historyService.getEntryByNoteIdOrAlias( + note, + req.user, + ); + return this.historyService.toHistoryEntryDto(foundEntry); + } catch (e) { + if (e instanceof NotInDBError) { + throw new NotFoundException(e.message); + } + throw e; + } + } + @UseGuards(TokenAuthGuard) @Put('history/:note') async updateHistoryEntry( @@ -86,13 +106,13 @@ export class MeController { @UseGuards(TokenAuthGuard) @Delete('history/:note') @HttpCode(204) - deleteHistoryEntry( + async deleteHistoryEntry( @Req() req: Request, @Param('note') note: string, ): Promise { // ToDo: Check if user is allowed to delete note try { - return this.historyService.deleteHistoryEntry(note, req.user); + await this.historyService.deleteHistoryEntry(note, req.user); } catch (e) { if (e instanceof NotInDBError) { throw new NotFoundException(e.message);