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
profilesanduserscollection with a value ofuidcorresponding to the value ofprofileIDand returns all of their fields ifprofileIDhas the same value asuid. - If
profileIDdoes not have the same value asuid, do the following:- Find the record from the
profilesanduserscollection with a a value ofuidcorresponding to the value of theprofileIDfield passed [404]. - Check if the value of the
uidpassed is not among those of theblockedfield of the foundprofile[403]. - Check if the found
userhas a value oftruefor itsactivefield and a value offalsefor itsdeactivatedfield [403]. - Check if the value of the passed
uidis among the values of thefollowingfield of the foundprofileif itsaccount_typehas a value ofghost[403]. - Set empty values for
followersandfollowingunless theaccount_typeof the foundprofileis set topublic. - Set blank value for
profile_pic,cover_imageandbiounless theaccount_typeof the foundprofileis set topublicorrestrictedor if the record contains the passeduidin itsfollowersfield. - Set blank value for
followers_lengthandfollowing_lengthunless theaccount_typeof the foundprofileis set topublicorrestrictedor if the record has anaccount_typeofprivateand contains the passeduidin itsfollowersfield. Anaccount_typeofghostwill always have everything linked to itsfollowersandfollowingset to hidden. - Set blank value for
highlightsunless theaccount_typeof the foundprofileis set topublicor if the record contains the passeduidin itsfollowersfield. - If the
account_typeof the foundprofileis set topublicor if the record contains the passeduidin itsfollowersfield, loop through eachhighlightin thehighlightsfield. Remove the highlight if it has avisibilityofnone, or if it is set tofollowersand the passeduidis not in theprofileof the currentuser’sfollowersfield. If the highlight has a visibility other thanpublic,followersornone, find theAccessGroupwith the value corresponding tovisibilityfor itsaccessIDfield and remove thathighlightifuidis not among the values of thatAccessGroup’smembersfield. - Filter and keep only the
profileID,nameandusernameof the found record if itsuidis among one of the values inside of theblockedfield of theprofileidentified by theuidpassed.
- Find the record from the