mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05:00
PublicAPI: Add /me/history/:note
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
521ddc36c6
commit
82ef4a10cb
1 changed files with 22 additions and 2 deletions
|
@ -59,6 +59,26 @@ export class MeController {
|
|||
);
|
||||
}
|
||||
|
||||
@UseGuards(TokenAuthGuard)
|
||||
@Get('history/:note')
|
||||
async getHistoryEntry(
|
||||
@Req() req: Request,
|
||||
@Param('note') note: string,
|
||||
): Promise<HistoryEntryDto> {
|
||||
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<void> {
|
||||
// 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);
|
||||
|
|
Loading…
Reference in a new issue