Join
/api/v2/group/join
Post
groups
profiles
jwt
Purpose
To allow a user to join an existing group.
Body Content [input]
{
uid: string,
groupID: string
}
Returns if valid [output]
{
message: string,
error: 0
}
What the API does
- Finds the
group
being referenced by thegroupID
passed [404]. - Checks if the
group
has aprivacy
set topublic
[401]. - Ensures that
uid
does not already correspond to a record in themembers
field with astatus
ofaccepted
orunauthorized
[403]. - Loops through the
group_invites
field of the record corresponding to theuid
passed from theprofiles
collection, setting any instance having the samegroupID
as that being referenced with astatus
ofpending
to have a value ofaccepted
instead. - Updates and saves the
group
with a new record (if it does not already exist) for themembers
field with theuid
passed, a value ofaccepted
for thestatus
field and usesfalse
as value for theis_admin
andhas_muted
fields.