Link Search Menu Expand Document

Fetch All

/api/v2/profile/fetch

Post

users

profiles

jwt

pgn


Purpose

To allow a user to fetch other entities’ profiles.

Body Content [input]

{
    uid: string
}

Returns if valid [output]

{
    profiles: {
        profileID: string,
        name: string,
        username: string,
        profile_pic: string,
        cover_image: string,
        bio: string,
        account_type: string,
        followers: string[],
        following: string[],
        followers_length: int,
        following_length: int,
        highlights: {
            highlightID: string,
            name: string,
            icon: string,
            storiesID: string[],
            visibility: string,
            created_on: Date
        }[]
    }[],
    error: 0,
    amount: int
}

What the API does

  • Find all records from the users and profiles collection with a uid not corresponding to the one passed.
  • Filter out the results by removing records which have the uid passed as a value included in their blocked field or which have a value of false for their active field or a value of true for their deactivated field.
  • Filter out the results by removing records which have an account_type of ghost and do not contain the passed uid in their following field.
  • Set empty values for followers and following unless the account_type is set to public.
  • Set blank value for profile_pic, cover_image and bio unless the account_type is set to public or restricted or if the record contains the passed uid in its followers field.
  • Set blank value for followers_length and following_length unless the account_type is set to public or restricted or if the record has an account_type of private and contains the passed uid in its followers field. An account_type of ghost will always have everything linked to its followers and following set to hidden.
  • Set blank value for highlights unless the account_type is set to public or if the record contains the passed uid in its followers field.
  • If account_type is set to public or if the record contains the passed uid in its followers field, loop through each highlight in the highlights field. Remove the highlight if it has a visibility of none, or if it is set to followers and the passed uid is not in the profile of the current user’s followers field. If the highlight has a visibility other than public, followers or none, find the AccessGroup with the value corresponding to visibility for its accessID field and remove that highlight if uid is not among the values of that AccessGroup’s members field.
  • Filter and keep only the profileID, name and username of any record if the uid is among one of the values inside of the blocked field of the profile identified by the uid passed.