From 466cf1903faa5f6776c51defe675af12d1c4989e Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sun, 7 Mar 2021 15:27:34 +0100 Subject: [PATCH] Can remove conversation image --- src/controllers/conversations_controller.rs | 10 ++++++++++ src/routes.rs | 1 + 2 files changed, 11 insertions(+) diff --git a/src/controllers/conversations_controller.rs b/src/controllers/conversations_controller.rs index 34890c0..49db413 100644 --- a/src/controllers/conversations_controller.rs +++ b/src/controllers/conversations_controller.rs @@ -121,6 +121,16 @@ pub fn change_image(r: &mut HttpRequestHandler) -> RequestResult { r.ok() } +/// Delete conversation image +pub fn delete_image(r: &mut HttpRequestHandler) -> RequestResult { + let conv_membership = r.post_conv_admin("convID")?; + let conv = conversations_helper::get_single(conv_membership.conv_id)?; + + conversations_helper::remove_conversation_image(&conv)?; + + r.ok() +} + /// Add a new member to a conversation pub fn add_member(r: &mut HttpRequestHandler) -> RequestResult { let conv_membership = r.post_conv("convID")?; diff --git a/src/routes.rs b/src/routes.rs index d96cce1..4166f70 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -195,6 +195,7 @@ pub fn get_routes() -> Vec { Route::post("/conversations/get_single", Box::new(conversations_controller::get_single)), Route::post("/conversations/updateSettings", Box::new(conversations_controller::update_settings)), Route::post("/conversations/change_image", Box::new(conversations_controller::change_image)), + Route::post("/conversations/delete_image", Box::new(conversations_controller::delete_image)), Route::post("/conversations/addMember", Box::new(conversations_controller::add_member)), Route::post("/conversations/setAdmin", Box::new(conversations_controller::set_admin)), Route::post("/conversations/removeMember", Box::new(conversations_controller::remove_member)),