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
profilecorresponding to theuidpassed and fetches a list of all values inside of thefollowingandblockedfields. - Finds all records from the
storiescollection. - Loops through each of these
storyrecords and:- Skip everything that follows if the record’s
uidhas a value equal to the one passed except for the last point. - 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 thefollowersfield of theprofilefetched. If that is not the case, remove that record. - If the current day / time minus the value of the
posted_onfield of thatstoryrecord is more than or equal to 24 hours, remove that record. - Remove the
viewsfield of thatstoryrecord. - Appends that
storyrecord to an array of stories to be returned.
- Skip everything that follows if the record’s