Fetch User
/api/v2/highlight/fetch/user
Post
stories
profiles
jwt
pgn
Purpose
To allow a user to fetch all related stories from highlights he/she is allowed to access for one specific user.
Body Content [input]
{
uid: string,
profileID: string
}
Returns if valid [output]
{
stories: {
uid: string,
storyID: string,
posted_on: Date,
content: String,
visibility: string
}[],
error: 0,
amount: int
}
What the API does
- Finds the
profilecorresponding to theuidpassed and fetches a list of all values inside of thefollowingandblockedfields. - Creates a new data structure:
allowedStories. - Find all records from the
profilescollection with auidfield corresponding to the value of theprofileIDfield passed. - Loops through these records and:
- Jump to the next value if the
uidpassed is a value included in theblockedfield of the current record or if itsuidis a value among theblockedfield obtained above. - Jump to the next value unless the
account_typeis set topublicor if the record contains the passeduidin itsfollowersfield. - Loop through each
highlightin thehighlightsfield, and:- Remove the highlight if it has a
visibilityofnone, or if it is set tofollowersand the passeduidis not in theprofileof the currentuser’sfollowersfield. If the highlight has a visibility other thanpublic, find theAccessGroupwith the value corresponding tovisibilityfor itsaccessIDfield and remove thathighlightifuidis not among the values of thatAccessGroup’smembersfield.
- Remove the highlight if it has a
- Append all the values from the
storiesIDfield of thehighlightfield to theallowedStoriesdata structure while guaranteeing that the data is always unique.
- Jump to the next value if the
- Finds all records from the
storiescollection having a value for theirstoryIDfield corresponding to one among those in theallowedStorieslist. - Loops through each of these
storyrecords and:- Skip everything that follows if the record’s
uidhas a value equal to the one passed. - Removes that record if it has a
visibilityset tonone. - If the record does not have a
visibilityofnone,followersorpublic, fetch themembersfield of theAccessGroupcorresponding to the value of thevisibilityfield and ifuidis not among the values of thatmembersfield, remove the record. - Removes that record if the value of its
uidfield is among that of the fetchedblockedfield above. - Finds the
profilethat has auidcorresponding to that of the currentstoryrecord, and removes that record if theblockedfield contains theuidpassed. - Else, if the record has a value of
followersfor its visibility field, check ifuidis among the values of thefollowingfield. If that is not the case, remove that record. - Remove the
viewsfield of thatstoryrecord.
- Skip everything that follows if the record’s