Create
/api/v2/room/create
Post
rooms
profiles
notifications
jwt
Purpose
To allow a user to create a chat room.
Body Content [input]
{
    uid: string,
    membersID: string[],
    name: string,
    description: string,
    icon: string,
    privacy: string
}
Returns if valid [output]
{
    roomID: string,
    error: 0
}
What the API does
- Ensures that privacy is either set to privateorpublic, and defaults topublic.
- Generates a roomID.
- Loops through membersIDwith each value corresponding tomemberIDand:- Fetches the profile for the record with a uidcorresponding to theuidpassed (src) [404].
- Fetches the profile for the record with a uidcorresponding tomemberID(dest) [404].
- Ensures that neither uidis found indest’sblockedfield nor thatmemberIDis found insrc’sblockedfield [403].
- Ensures that uidis found indest’sfollowersfield [403].
- Saves a new inviteindest’schat_inviteswith the generatedroomIDand usespendingas value for thestatefield.
- Generates a new notificationIDand atimestampcorresponding to the current date and time, and creates a new object in thenotificationscollection with the following data:{ uid: memberID, notificationID: notificationID, content: `uid.${uid} invited you to the room.${roomID} chat room`, profileID: uid, type: "room_invite", created_on: timestamp, read: false, redirect: `/chat/${roomID}` }
 
- Fetches the profile for the record with a 
- Generates a new object with the passed name,description,privacy,iconand the generatedroomID. Empty values will be used formessagesandthreads. Records will be added to themembersfield with each one corresponding to the current user’suid, with a value offalseforis_adminandhas_muted, and uses a value ofpendingfor thestatusfield. A record will be similarly created for the current user using theuidpassed, but with values oftrueforis_admin,falseforhas_mutedandacceptedforstatus.