From d23411dca7063abdc9d853547a5f15fc64ce44a2 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 10 Jul 2020 09:02:16 +0200 Subject: [PATCH] Can delete a comment --- src/controllers/comments_controller.rs | 9 +++++++++ src/controllers/routes.rs | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/controllers/comments_controller.rs b/src/controllers/comments_controller.rs index 6ba9f1f..ba3882f 100644 --- a/src/controllers/comments_controller.rs +++ b/src/controllers/comments_controller.rs @@ -66,4 +66,13 @@ pub fn edit(r: &mut HttpRequestHandler) -> RequestResult { comments_helper::edit(comment.id, &new_content)?; r.success("Content updated.") +} + +/// Delete a comment +pub fn delete(r: &mut HttpRequestHandler) -> RequestResult { + let comment = r.post_comment_with_full_access("commentID")?; + + comments_helper::delete(&comment)?; + + r.success("Comment deleted.") } \ No newline at end of file diff --git a/src/controllers/routes.rs b/src/controllers/routes.rs index c772422..04cba51 100644 --- a/src/controllers/routes.rs +++ b/src/controllers/routes.rs @@ -223,7 +223,9 @@ pub fn get_routes() -> Vec { Route::post("/comments/get_single", Box::new(comments_controller::get_single)), - Route::post("/comments/edit",Box::new(comments_controller::edit)), + Route::post("/comments/edit", Box::new(comments_controller::edit)), + + Route::post("/comments/delete", Box::new(comments_controller::delete)),