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
andprofiles
collection with auid
not corresponding to the one passed. - Filter out the results by removing records which have the
uid
passed as a value included in theirblocked
field or which have a value offalse
for theiractive
field or a value oftrue
for theirdeactivated
field. - Filter out the results by removing records which have an
account_type
ofghost
and do not contain the passeduid
in theirfollowing
field. - Set empty values for
followers
andfollowing
unless theaccount_type
is set topublic
. - Set blank value for
profile_pic
,cover_image
andbio
unless theaccount_type
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
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
is set topublic
or if the record contains the passeduid
in itsfollowers
field. - If
account_type
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 any record if theuid
is among one of the values inside of theblocked
field of theprofile
identified by theuid
passed.