Fetch User
/api/v2/feed/fetch/user
Post
posts
profiles
groups
users
jwt
pgn
Purpose
To allow a user to fetch all the posts of one specific user.
Body Content [input]
{
uid: string,
profileID: string
}
Returns if valid [output]
{
posts: {
uid: string,
postID: string,
content: string,
posted_on: Date,
modified_on: Date,
reacts: string[],
groupID: string,
shareID: string,
comments: {
uid: string,
commentID: string,
reply_to: string,
posted_on: Date,
modified_on: Date,
reacts: string[],
visibility: string
}[],
visibility: string,
allow_comments: bool,
senderName: string,
senderUsername: string
}[],
error: 0,
amount: int
}
What the API does
- Finds the
profilecorresponding to theuidpassed and fetches a list of all values inside of thefollowingandblockedfields. - If the value of the
uidfield passed is the same as that of theprofileIDfield passed, returns thepostshaving a value for theiruidfield corresponding to the one passed and sorts them in descending order based on the value of theirposted_onfield. - Finds all records from the
postscollection having auidnot corresponding to the one passed. - Loops through each of these
postrecords and:- 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. - Remove that record if it has a visibility set to
none. - 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 currentpostrecord, and removes that record if theblockedfield contains theuidpassed. - If the record has a value for its
groupIDfield, find thegroupcorresponding to thatgroupIDand check ifuidis a value among thatgroup’smembersfield with astatusofaccepted. If that is not the case and if thegrouphas a value ofprivatefor itsprivacyfield, remove that record. - Loop through each of the
commentof thecommentsfield of that record and:- Create a new data structure
removedCommentsfor thecommentIDs of removedcomments. - Remove that
commentif it has avisibilityset tonone. - If the
commentdoes not have avisibilityofnone,followersorpublic, fetch themembersfield of theAccessGroupcorresponding to the value of thevisibilityfield and ifuidis not among the values of thatmembersfield, remove thecomment. - Removes that
commentif the value of itsuidfield is among those of the fetchedblockedfield above. - Finds the
profilethat has auidcorresponding to that of the currentcomment, and removes thatcommentif theuidpassed is among the values ofblockedfield. - If the
commenthas avisibilityoffollowersfetch thefollowersfield of theprofilecorresponding to the value of theuidfield of thatcommentand ifuidis not among these values or is not equal to the value of theuidfield of thecommentitself, remove thecomment. - Append the value of the
commentIDfield of all removedcomments toremovedComments. - Loop through all
comments again, and remove all those who have a value for theirreply_tofield corresponding to a value inside of theremovedCommentsarray.
- Create a new data structure
- Removes that record if it has a
- Filters out the
posts, keeping only those having a value for theiruidfield that corresponds to that of theprofileIDfield passed. - Sort all the
postsby date in descending order of when they were posted based on the value of theirposted_onfield. - Adds a
senderNameandsenderUsernamefield to each of thepostshaving a value equal to that of thenameandusernameof theuserwho posted it identified by the value of itsuidfield.