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
groupbeing referenced by thegroupIDpassed [404]. - Ensures that
uidcorresponds to a record in themembersfield with astatusofacceptedand has a value oftruefor itsis_adminfield [403]. - Updates and saves the
groupwith the new value(s) forname,description,icon,cover_imageand/orprivacy. - Loops through each of the
memberof themembersarray of thatgrouphaving a status ofacceptedand a value offalsefor itshas_mutedfield and generates a newnotificationIDand atimestampcorresponding to the current date and time, and creates a new object in thenotificationscollection 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}` }