Delete
/api/v2/message/delete
Post
rooms
jwt
Purpose
To allow a user to delete a sent message in a chat room that he/she is a member of.
Body Content [input]
{
uid: string,
roomID: string,
messageID: 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]. - If
is_thread
has a value offalse
, set the value of theis_deleted
field of the object from themessages
field of theroom
corresponding tomessageID
totrue
. - Else if
is_thread
has a value oftrue
, set the value of theis_deleted
field of the object from thethreads
field of theroom
corresponding tomessageID
totrue
.