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
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]. - If
is_threadhas a value offalse, set the value of theis_deletedfield of the object from themessagesfield of theroomcorresponding tomessageIDtotrue. - Else if
is_threadhas a value oftrue, set the value of theis_deletedfield of the object from thethreadsfield of theroomcorresponding tomessageIDtotrue.