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:
@@ -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!")
|
||||
}
|
Reference in New Issue
Block a user