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 thegroupID
passed [404]. - Ensures that
uid
corresponds to a record in themembers
field with astatus
ofaccepted
and has a value oftrue
for itsis_admin
field [403]. - Updates and saves the
group
with the new value(s) forname
,description
,icon
,cover_image
and/orprivacy
. - Loops through each of the
member
of themembers
array of thatgroup
having a status ofaccepted
and a value offalse
for itshas_muted
field and generates a newnotificationID
and atimestamp
corresponding to the current date and time, and creates a new object in thenotifications
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}` }