Edit
/api/v2/message/edit
Post
rooms
jwt
Purpose
To allow a user to edit a sent message in a chat room that he/she is a member of.
Body Content [input]
{
uid: string,
roomID: string,
messageID: string,
message: string,
is_thread: bool
}
Returns if valid [output]
{
message: string,
error: 0
}
What the API does
- Finds the record from the
roomscollection corresponding to theroomIDpassed [404]. - Ensures that
uidcorresponds to a record in themembersfield of that record with astatusofaccepted[403]. - If
is_threadhas a value offalse, find themessagebeing referenced in themessagesfield having the same value ofmessageIDas that passed, else ifis_threadhas a value oftruefind that being referenced from thethreadsfield [404]. - Checks that the
senderIDfield of the foundmessagehas the same value as that of theuidpassed [403]. - Generates a
timestampfor the current date and time. - If
is_threadhas a value offalse, updates the object in themessagesfield of theroomcorresponding tomessageID, with the updated value formessageand uses the value of the generatedtimestampfor the value of themodified_onfield. - Else if
is_threadhas a value oftrue, updates the object in thethreadsfield of theroomcorresponding tomessageID, with the updated value formessageand uses the value of the generatedtimestampfor the value of themodified_onfield.