From c83d722c8227aa1e3bb56f118ca4a14a1f588376 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 21 Mar 2020 12:04:04 +0100 Subject: [PATCH] Can delete a comment --- src/controllers/CommentsController.ts | 13 +++++++++++++ src/controllers/Routes.ts | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/controllers/CommentsController.ts b/src/controllers/CommentsController.ts index 61bc048..5f81064 100644 --- a/src/controllers/CommentsController.ts +++ b/src/controllers/CommentsController.ts @@ -76,6 +76,19 @@ export class CommentsController { h.success() } + /** + * Delete a comment + * + * @param h Request handler + */ + public static async Delete(h: RequestHandler) { + const commentID = await this.GetPostCommentIDWithFullAccess(h, "commentID"); + + await CommentsHelper.Delete(await CommentsHelper.GetSingle(commentID)); + + h.success(); + } + /** * Get the content of a comment included in a POST field * diff --git a/src/controllers/Routes.ts b/src/controllers/Routes.ts index 175858e..727015a 100644 --- a/src/controllers/Routes.ts +++ b/src/controllers/Routes.ts @@ -211,6 +211,8 @@ export const Routes : Route[] = [ {path: "/comments/edit", cb: (h) => CommentsController.Edit(h)}, + {path: "/comments/delete", cb: (h) => CommentsController.Delete(h)}, + // Notifications controller {path: "/notifications/count_unread", cb: (h) => NotificationsController.CountUnread(h)},