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
andusers
collection with a value ofuid
corresponding to the value ofprofileID
and returns all of their fields ifprofileID
has the same value asuid
. - If
profileID
does not have the same value asuid
, do the following:- Find the record from the
profiles
andusers
collection with a a value ofuid
corresponding to the value of theprofileID
field passed [404]. - Check if the value of the
uid
passed is not among those of theblocked
field of the foundprofile
[403]. - Check if the found
user
has a value oftrue
for itsactive
field and a value offalse
for itsdeactivated
field [403]. - Check if the value of the passed
uid
is among the values of thefollowing
field of the foundprofile
if itsaccount_type
has a value ofghost
[403]. - Set empty values for
followers
andfollowing
unless theaccount_type
of the foundprofile
is set topublic
. - Set blank value for
profile_pic
,cover_image
andbio
unless theaccount_type
of the foundprofile
is set topublic
orrestricted
or if the record contains the passeduid
in itsfollowers
field. - Set blank value for
followers_length
andfollowing_length
unless theaccount_type
of the foundprofile
is set topublic
orrestricted
or if the record has anaccount_type
ofprivate
and contains the passeduid
in itsfollowers
field. Anaccount_type
ofghost
will always have everything linked to itsfollowers
andfollowing
set to hidden. - Set blank value for
highlights
unless theaccount_type
of the foundprofile
is set topublic
or if the record contains the passeduid
in itsfollowers
field. - If the
account_type
of the foundprofile
is set topublic
or if the record contains the passeduid
in itsfollowers
field, loop through eachhighlight
in thehighlights
field. Remove the highlight if it has avisibility
ofnone
, or if it is set tofollowers
and the passeduid
is not in theprofile
of the currentuser
’sfollowers
field. If the highlight has a visibility other thanpublic
,followers
ornone
, find theAccessGroup
with the value corresponding tovisibility
for itsaccessID
field and remove thathighlight
ifuid
is not among the values of thatAccessGroup
’smembers
field. - Filter and keep only the
profileID
,name
andusername
of the found record if itsuid
is among one of the values inside of theblocked
field of theprofile
identified by theuid
passed.
- Find the record from the