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_requestsfield of the record having the same value for itsuidfield as that passed and update all other records in theprofilescollection to removeuidfrom theirsent_follow_requestsfield. - Updates and saves the current record with the new value(s) for the
bio,prefer_dark,language,account_type,sent_follow_requestsprofile_pic, and/orcover_imagefield(s). - Generates a new
notificationIDand atimestampcorresponding to the current date and time, and creates a new object in thenotificationscollection 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/" }