Fetch All
/api/v2/highlight/fetch
Post
stories
profiles
jwt
pgn
Purpose
To allow a user to fetch all related stories from highlights he/she is allowed to access.
Body Content [input]
{
uid: 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
profile
corresponding to theuid
passed and fetches a list of all values inside of thefollowing
andblocked
fields. - Creates a new data structure:
allowedStories
. - Find all records from the
profiles
collection with auid
not corresponding to the one passed. - Loops through these records and:
- Jump to the next value if the
uid
passed is a value included in theblocked
field of the current record or if itsuid
is a value among theblocked
field obtained above. - Jump to the next value unless the
account_type
is set topublic
or if the record contains the passeduid
in itsfollowers
field. - Loop through each
highlight
in thehighlights
field, and:- Remove the highlight if it has a
visibility
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
, find theAccessGroup
with the value corresponding tovisibility
for itsaccessID
field and remove thathighlight
ifuid
is not among the values of thatAccessGroup
’smembers
field.
- Remove the highlight if it has a
- Append all the values from the
storiesID
field of thehighlight
field to theallowedStories
data structure while guaranteeing that the data is always unique.
- Jump to the next value if the
- Finds all records from the
stories
collection having a value for theirstoryID
field corresponding to one among those in theallowedStories
list. - Loops through each of these
story
records and:- Skip everything that follows if the record’s
uid
has a value equal to the one passed. - Removes that record if it has a
visibility
set tonone
. - If the record does not have a
visibility
ofnone
,followers
orpublic
, fetch themembers
field of theAccessGroup
corresponding to the value of thevisibility
field and ifuid
is not among the values of thatmembers
field, remove the record. - Removes that record if the value of its
uid
field is among that of the fetchedblocked
field above. - Finds the
profile
that has auid
corresponding to that of the currentstory
record, and removes that record if theblocked
field contains theuid
passed. - Else, if the record has a value of
followers
for its visibility field, check ifuid
is among the values of thefollowing
field. If that is not the case, remove that record. - Remove the
views
field of thatstory
record.
- Skip everything that follows if the record’s