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
rooms
collection corresponding to theroomID
passed [404]. - Ensures that
uid
corresponds to a record in themembers
field of that record with astatus
ofaccepted
[403]. - If
is_thread
has a value offalse
, find themessage
being referenced in themessages
field having the same value ofmessageID
as that passed, else ifis_thread
has a value oftrue
find that being referenced from thethreads
field [404]. - Checks that the
senderID
field of the foundmessage
has the same value as that of theuid
passed [403]. - Generates a
timestamp
for the current date and time. - If
is_thread
has a value offalse
, updates the object in themessages
field of theroom
corresponding tomessageID
, with the updated value formessage
and uses the value of the generatedtimestamp
for the value of themodified_on
field. - Else if
is_thread
has a value oftrue
, updates the object in thethreads
field of theroom
corresponding tomessageID
, with the updated value formessage
and uses the value of the generatedtimestamp
for the value of themodified_on
field.