Can update the content of a conversation message

This commit is contained in:
Pierre HUBERT
2018-08-29 13:36:27 +02:00
parent 2749dbcb3f
commit 9df1c93a24
2 changed files with 46 additions and 0 deletions

View File

@ -480,6 +480,34 @@ class ConversationsController {
return array("success" => "The conversation has been deleted");
}
/**
* Update the content of a conversation message
*
* @url POST /conversations/updateMessage
*/
public function updateMessage(){
user_login_required();
$messageID = postInt("messageID");
$newContent = postString("content");
if(!check_string_before_insert($newContent))
Rest_fatal_error(401, "Invalid new message content!");
//Check whether the user own or not conversation message
if(!components()->conversations->isOwnerMessage(userID, $messageID))
Rest_fatal_error(401, "You do not own this conversation message!");
//Update the message
$message = new ConversationMessage();
$message->set_id($messageID);
$message->set_message($newContent);
if(!components()->conversations->updateMessage($message))
Rest_fatal_error(500, "Could not update the content of the message!");
return array("success" => "The conversation message has been successfully updated!");
}
/**
* Delete a conversation message
*