Accept
/api/v2/room/accept
Post
rooms
profiles
jwt
Purpose
To allow a user to accept or refuse an invitation to join a chat room.
Body Content [input]
{
    uid: string,
    roomID: string,
    action: 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 [403]. - Ensures that that record in the 
membersfield does not have astatusofacceptedorunauthorized[403]. - Ensures that 
actionhas a value ofacceptorreject[400]. - Loops through the 
chat_invitesfield of the record corresponding to theuidpassed from theprofilescollection, finding any instance having the sameroomIDas that being referenced and having a value ofpendingfor thestatusfield [403]. - Sets that/those instance(s) to have a 
statusofacceptedifactionis set toacceptelse,statuswill have a value ofrejected. - Updates and saves the 
roomwith the record in themembersfield referenced by theuidpassed to have a status ofacceptedifactionis set toacceptelse, removes the record. - Generates a 
messageIDandtimestampcorresponding to the current date and time ifactionis set toaccept. - 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 forviewsifactionis set toaccept.