Fetch
/api/v2/feed/fetch/one
Post
posts
profiles
groups
users
jwt
Purpose
To allow a user to fetch one of the posts from users that he/she follows that he/she is allowed to see in his/her feed.
Body Content [input]
{
    uid: string,
    postID: string
}
Returns if valid [output]
{
    post: {
        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,
        groupName: string
    },
    error: 0
}
What the API does
- Finds the 
profilecorresponding to theuidpassed and fetches a list of all values inside of thefollowingandblockedfields. - Finds all records from the 
postscollection. - 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 
 - Finds the 
postcorresponding to the value of thepostIDfield passed [404]. - Adds a 
senderNameandsenderUsernamefield to theposthaving a value equal to that of thenameandusernameof theuserwho posted it identified by the value of itsuidfield. - Adds a 
groupNamefield to thepostcorresponding to thenameof thegroupif it has a value for itsgroupIDfield.