Link Search Menu Expand Document

Update

/api/v2/group/update

Post

groups

notifications

jwt


Purpose

To allow a user to update an existing group.

Body Content [input]

{
    uid: string,
    groupID: string,
    name: string,
    description: string,
    icon: string,
    cover_image: string,
    privacy: 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 with a status of accepted and has a value of true for its is_admin field [403].
  • Updates and saves the group with the new value(s) for name, description, icon, cover_image and/or privacy.
  • Loops through each of the member of the members array of that group having a status of accepted and a value of false for its has_muted field and generates a new notificationID and a timestamp corresponding to the current date and time, and creates a new object in the notifications collection with the following data:
    {
      uid: member.uid,
      notificationID: notificationID,
      content: `Some info have been updated in the group.${groupID} group`,
      profileID: uid,
      type: "group_update",
      created_on: timestamp,
      read: false,
      redirect: `/group/${groupID}`
    }