1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-09-25 22:29:45 +00:00

Can delete a single conversation message

This commit is contained in:
2020-06-23 14:09:52 +02:00
parent a5c83cc1b4
commit abf9a7fa82
3 changed files with 27 additions and 0 deletions

View File

@@ -312,4 +312,17 @@ pub fn update_message(r: &mut HttpRequestHandler) -> RequestResult {
conversations_helper::update_message_content(msg_id, &new_content)?;
r.success("Conversation message content successfully updated")
}
/// Delete a conversation message
pub fn delete_message(r: &mut HttpRequestHandler) -> RequestResult {
let msg_id = r.post_u64("messageID")?;
if !conversations_helper::is_message_owner(r.user_id()?, msg_id)? {
r.forbidden("You are not the owner of this message!".to_string())?;
}
conversations_helper::delete_message_by_id(msg_id)?;
r.success("The message has been successfully deleted!")
}