Join
/api/v2/room/join
Post
rooms
profiles
jwt
Purpose
To allow a user to join an existing chat room.
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]. - Checks if the
roomhas aprivacyset topublic[401]. - Ensures that
uiddoes not already correspond to a record in themembersfield with astatusofacceptedorunauthorized[403]. - Loops through the
chat_invitesfield of the record corresponding to theuidpassed from theprofilescollection, setting any instance having the sameroomIDas that being referenced with astatusofpendingto have a value ofacceptedinstead. - Updates and saves the
roomwith a new record (if it does not already exist) for themembersfield with theuidpassed, a value ofacceptedfor thestatusfield and usesfalseas value for theis_adminandhas_mutedfields. - Generates a
messageIDandtimestampcorresponding to the current date and time. - Generates and saves a new object in the
messagesfield of theroomusingmessageID, “uid.${uid} has joined the chat” asmessage,timestampascreated_onandmodified_on, “_system” assenderID,falseforis_deletedand an empty array forviews.