mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-20 16:45:16 +00:00
Can update conversation message content
This commit is contained in:
@ -319,6 +319,27 @@ export class ConversationsController {
|
||||
h.success("The conversation has been deleted.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the content of a conversation message
|
||||
*
|
||||
* @param h Request handler
|
||||
*/
|
||||
public static async UpdateMessage(h: RequestHandler) {
|
||||
const messageID = h.postInt("messageID");
|
||||
const newContent = h.postString("content");
|
||||
|
||||
if(newContent.length < 3)
|
||||
h.error(401, "Invalid new message content!");
|
||||
|
||||
// Check out whether the user own the message or not
|
||||
if(!await ConversationsHelper.IsUserMessageOwner(h.getUserId(), messageID))
|
||||
h.error(401, "You do not own this conversation message!");
|
||||
|
||||
await ConversationsHelper.UpdateMessageContent(messageID, newContent);
|
||||
|
||||
h.success("Conversation message content successfully update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get and return safely a conversation ID specified in a $_POST Request
|
||||
*
|
||||
|
@ -72,6 +72,8 @@ export const Routes : Route[] = [
|
||||
{path: "/conversations/get_list_unread", cb: (h) => ConversationsController.GetListUnread(h)},
|
||||
|
||||
{path: "/conversations/delete", cb: (h) => ConversationsController.DeleteConversation(h)},
|
||||
|
||||
{path: "/conversations/updateMessage", cb: (h) => ConversationsController.UpdateMessage(h)},
|
||||
|
||||
|
||||
// Search controller
|
||||
|
Reference in New Issue
Block a user