mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 19:26: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)
|
@UseGuards(TokenAuthGuard)
|
||||||
@Put('history/:note')
|
@Put('history/:note')
|
||||||
async updateHistoryEntry(
|
async updateHistoryEntry(
|
||||||
|
@ -86,13 +106,13 @@ export class MeController {
|
||||||
@UseGuards(TokenAuthGuard)
|
@UseGuards(TokenAuthGuard)
|
||||||
@Delete('history/:note')
|
@Delete('history/:note')
|
||||||
@HttpCode(204)
|
@HttpCode(204)
|
||||||
deleteHistoryEntry(
|
async deleteHistoryEntry(
|
||||||
@Req() req: Request,
|
@Req() req: Request,
|
||||||
@Param('note') note: string,
|
@Param('note') note: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
// ToDo: Check if user is allowed to delete note
|
// ToDo: Check if user is allowed to delete note
|
||||||
try {
|
try {
|
||||||
return this.historyService.deleteHistoryEntry(note, req.user);
|
await this.historyService.deleteHistoryEntry(note, req.user);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof NotInDBError) {
|
if (e instanceof NotInDBError) {
|
||||||
throw new NotFoundException(e.message);
|
throw new NotFoundException(e.message);
|
||||||
|
|
Loading…
Reference in a new issue