Fetch All
/api/v2/story/fetch
Post
stories
profiles
jwt
pgn
Purpose
To allow a user to fetch all the stories from users that he/she follows that he/she is allowed to see in his/her feed.
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. - Finds all records from the
stories
collection. - 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 except for the last point. - 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 thefollowers
field of theprofile
fetched. If that is not the case, remove that record. - If the current day / time minus the value of the
posted_on
field of thatstory
record is more than or equal to 24 hours, remove that record. - Remove the
views
field of thatstory
record. - Appends that
story
record to an array of stories to be returned.
- Skip everything that follows if the record’s