Accept
/api/v2/group/accept
Post
groups
profiles
jwt
Purpose
To allow a user to accept or refuse an invitation to join a group.
Body Content [input]
{
uid: string,
groupID: string,
action: string
}
Returns if valid [output]
{
message: string,
error: 0
}
What the API does
- Finds the
group
being referenced by thegroupID
passed [404]. - Ensures that
uid
corresponds to a record in themembers
field [403]. - Ensures that that record in the
members
field does not have astatus
ofaccepted
orunauthorized
[403]. - Ensures that
action
has a value ofaccept
orreject
[400]. - Loops through the
group_invites
field of the record corresponding to theuid
passed from theprofiles
collection, finding any instance having the samegroupID
as that being referenced and having a value ofpending
for thestatus
field [403]. - Sets that/those instance(s) to have a
status
ofaccepted
ifaction
is set toaccept
else,status
will have a value ofrejected
. - Updates and saves the
group
with the record in themembers
field referenced by theuid
passed to have a status ofaccepted
ifaction
is set toaccept
else, removes the record.