From dfd36ac4e5afc21628e7acaa31d042e767f45fe2 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 20 Mar 2020 18:47:28 +0100 Subject: [PATCH] Ready to implement post deletion --- src/controllers/PostsController.ts | 13 +++++++++++++ src/controllers/Routes.ts | 2 ++ src/helpers/PostsHelper.ts | 9 +++++++++ 3 files changed, 24 insertions(+) diff --git a/src/controllers/PostsController.ts b/src/controllers/PostsController.ts index e9695f4..961c525 100644 --- a/src/controllers/PostsController.ts +++ b/src/controllers/PostsController.ts @@ -334,6 +334,19 @@ export class PostsController { h.success(); } + /** + * Delete a post + * + * @param h Request handler + */ + public static async DeletePost(h: RequestHandler) { + const postID = await h.postPostIDWithAccess("postID", PostAccessLevel.INTERMEDIATE_ACCESS); + + await PostsHelper.Delete(postID); + + h.success(); + } + /** * Send multiple posts to the API * diff --git a/src/controllers/Routes.ts b/src/controllers/Routes.ts index 9668a21..cb06747 100644 --- a/src/controllers/Routes.ts +++ b/src/controllers/Routes.ts @@ -198,6 +198,8 @@ export const Routes : Route[] = [ {path: "/posts/update_content", cb: (h) => PostsController.UpdateContent(h)}, + {path: "/posts/delete", cb: (h) => PostsController.DeletePost(h)}, + // Notifications controller diff --git a/src/helpers/PostsHelper.ts b/src/helpers/PostsHelper.ts index c49c69b..c620607 100644 --- a/src/helpers/PostsHelper.ts +++ b/src/helpers/PostsHelper.ts @@ -478,6 +478,15 @@ export class PostsHelper { }) } + /** + * Delete a post + * + * @param postID The ID of the post to delete + */ + public static async Delete(postID: number) { + + } + /** * Turn a database entry into a row object *