Leave
/api/v2/room/leave
Post
rooms
jwt
Purpose
To allow a user to leave a chat room that he/she is already a member of.
Body Content [input]
{
uid: string,
roomID: string
}
Returns if valid [output]
{
message: string,
error: 0
}
What the API does
- Finds the
roombeing referenced by theroomIDpassed [404]. - Ensures that
uidcorresponds to a record in themembersfield with astatusofaccepted[403]. - Generates a
messageIDandtimestampcorresponding to the current date and time. - Generates and saves a new object in the
messagesfield of theroomusingmessageID, “uid.${uid} has left the chat” asmessage,timestampascreated_onandmodified_on, “_system” assenderID,falseforis_deletedand an empty array forviews. - Removes the record in the
membersfield corresponding touidfrom theroom.