Link Search Menu Expand Document

Request

/api/v2/profile/request

Post

profiles

notifications

jwt


Purpose

To allow a user to accept or decline a follow request.

Body Content [input]

{
    uid: string,
    profileID: string,
    accept: bool
}

Returns if valid [output]

{
    message: string,
    error: 0
}

What the API does

  • Checks that uid and profileID are not the same value [403].
  • Fetches the profile for the record with a uid corresponding to the uid passed (receptor) [404].
  • Fetches the profile for the record with a uid corresponding to the profileID passed (sender) [404].
  • Ensure that neither uid is found in sender’s blocked field nor that profileID is found in receptor’s blocked field [403].
  • Ensure that profileID is in receptor’s received_follow_requests field [403].
  • If receptor’s account_type is set to private or restricted, do the following:
    • Remove profileID from receptor’s received_follow_requests.
    • Remove uid from sender’s sent_follow_requests.
    • Append profileID in receptor’s followers if accept is equal to true.
    • Append uid in sender’s following if accept is equal to true.
  • Do the same thing as above if receptor’s account_type is set to ghost and it it has profileID as value among its following field [403].
  • 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 if accept is equal to true:
    {
      uid: profileID,
      notificationID: notificationID,
      content: `You are now following uid.${uid}`,
      profileID: uid,
      type: "follow_accept",
      created_on: timestamp,
      read: false,
      redirect: `/profile/${uid}`
    }