Link Search Menu Expand Document

Fetch

/api/v2/profile/fetch/current

Post

profiles

users

jwt


Purpose

To allow a user to fetch his/her profile or that of another member.

Body Content [input]

{
    uid: string,
    profileID: string
}

Returns if valid [output]

{
    uid: string,
    bio: string,
    profile_pic: string,
    cover_image: string,
    followers: string[],
    following: string[],
    followers_length: int,
    following_length: int,
    blocked: string[],
    prefer_dark: bool,
    language: string,
    account_type: string,
    collections: {
        collectionID: string,
        name: string,
        posts: string[]
    }[],
    received_follow_requests: string[],
    sent_follow_requests: string[],
    chat_invites: {
        roomID: string,
        state: string
    }[],
    group_invites: {
        roomID: string,
        state: string
    }[],
    searches: string[],
    access_groups: {
        accessID: string,
        name: string,
        members: string[]
    }[],
    highlights: {
        highlightID: string,
        name: string,
        icon: string,
        storiesID: string[],
        views: string[],
        visibility: string,
        created_on: Date
    }[],
    error: 0
}
{
    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
}

What the API does

  • Finds the record from the profiles and users collection with a value of uid corresponding to the value of profileID and returns all of their fields if profileID has the same value as uid.
  • If profileID does not have the same value as uid, do the following:
    • Find the record from the profiles and users collection with a a value of uid corresponding to the value of the profileID field passed [404].
    • Check if the value of the uid passed is not among those of the blocked field of the found profile [403].
    • Check if the found user has a value of true for its active field and a value of false for its deactivated field [403].
    • Check if the value of the passed uid is among the values of the following field of the found profile if its account_type has a value of ghost [403].
    • Set empty values for followers and following unless the account_type of the found profile is set to public.
    • Set blank value for profile_pic, cover_image and bio unless the account_type of the found profile 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 of the found profile 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 of the found profile is set to public or if the record contains the passed uid in its followers field.
    • If the account_type of the found profile 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 the found record if its uid is among one of the values inside of the blocked field of the profile identified by the uid passed.