Link Search Menu Expand Document

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 the received_follow_requests field of the record having the same value for its uid field as that passed and update all other records in the profiles collection to remove uid from their sent_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/or cover_image field(s).
  • 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: uid,
      notificationID: notificationID,
      content: "Details about your profile just got updated",
      profileID: uid,
      type: "profile_update",
      created_on: timestamp,
      read: false,
      redirect: "/profile/"
    }