Link Search Menu Expand Document

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 the groupID passed [404].
  • Ensures that uid corresponds to a record in the members field [403].
  • Ensures that that record in the members field does not have a status of accepted or unauthorized [403].
  • Ensures that action has a value of accept or reject [400].
  • Loops through the group_invites field of the record corresponding to the uid passed from the profiles collection, finding any instance having the same groupID as that being referenced and having a value of pending for the status field [403].
  • Sets that/those instance(s) to have a status of accepted if action is set to accept else, status will have a value of rejected.
  • Updates and saves the group with the record in the members field referenced by the uid passed to have a status of accepted if action is set to accept else, removes the record.