Update
/api/v2/profile/update
Post
profiles
notifications
jwt
Purpose
To allow a user to update some details about his/her profile.
Body Content [input]
{
uid: string,
bio: string,
prefer_dark: bool,
language: string,
account_type: string,
profile_pic_url: string,
cover_image_url: string,
}
Returns if valid [output]
{
message: string,
error: 0
}
What the API does
- Checks if there is at least one other non-empty field passed except
uid
. - If there is a change in
account_type
, reset the value of thereceived_follow_requests
field of the record having the same value for itsuid
field as that passed and update all other records in theprofiles
collection to removeuid
from theirsent_follow_requests
field. - Updates and saves the current record with the new value(s) for the
bio
,prefer_dark
,language
,account_type
,sent_follow_requests
profile_pic
, and/orcover_image
field(s). - Generates a new
notificationID
and atimestamp
corresponding to the current date and time, and creates a new object in thenotifications
collection with the following data:{ uid: uid, notificationID: notificationID, content: "Details about your profile just got updated", profileID: uid, type: "profile_update", created_on: timestamp, read: false, redirect: "/profile/" }