Fetch Group
/api/v2/feed/fetch/group
Post
posts
profiles
groups
users
jwt
pgn
Purpose
To allow a user to fetch all the posts found in one specific group.
Body Content [input]
{
    uid: string,
    groupID: 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,
        groupName: 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 the 
groupbeing referenced using the value of thegroupIDfield passed [404]. - Checks if the found 
grouphas a value for itsprivacyfield that is set topublicor if there is a record in itsmembersfield with auidcorresponding to the one passed and with astatusofaccepted[403]. - Finds all records from the 
postscollection having a value for theirgroupIDfield 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. - 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 
 - 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. - Adds a 
groupNamefield to each of thepostscorresponding to thenameof thegroupif they have a value for theirgroupIDfield.