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
room
being referenced by theroomID
passed [404]. - Ensures that
uid
corresponds to a record in themembers
field with astatus
ofaccepted
[403]. - Generates a
messageID
andtimestamp
corresponding to the current date and time. - Generates and saves a new object in the
messages
field of theroom
usingmessageID
, “uid.${uid
} has left the chat” asmessage
,timestamp
ascreated_on
andmodified_on
, “_system” assenderID
,false
foris_deleted
and an empty array forviews
. - Removes the record in the
members
field corresponding touid
from theroom
.