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
groupbeing referenced by thegroupIDpassed [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
group_invitesfield of the record corresponding to theuidpassed from theprofilescollection, finding any instance having the samegroupIDas 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
groupwith the record in themembersfield referenced by theuidpassed to have a status ofacceptedifactionis set toacceptelse, removes the record.