Link Search Menu Expand Document

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 profile corresponding to the uid passed and fetches a list of all values inside of the following and blocked fields.
  • If the value of the uid field passed is the same as that of the profileID field passed, returns the posts having a value for their uid field corresponding to the one passed and sorts them in descending order based on the value of their posted_on field.
  • Finds all records from the posts collection having a uid not corresponding to the one passed.
  • Loops through each of these post records and:
    • Removes that record if it has a visibility set to none.
    • If the record does not have a visibility of none, followers or public, fetch the members field of the AccessGroup corresponding to the value of the visibility field and if uid is not among the values of that members field, remove the record.
    • Remove that record if it has a visibility set to none.
    • Removes that record if the value of its uid field is among that of the fetched blocked field above.
    • Finds the profile that has a uid corresponding to that of the current post record, and removes that record if the blocked field contains the uid passed.
    • If the record has a value for its groupID field, find the group corresponding to that groupID and check if uid is a value among that group’s members field with a status of accepted. If that is not the case and if the group has a value of private for its privacy field, remove that record.
    • Loop through each of the comment of the comments field of that record and:
      • Create a new data structure removedComments for the commentIDs of removed comments.
      • Remove that comment if it has a visibility set to none.
      • If the comment does not have a visibility of none, followers or public, fetch the members field of the AccessGroup corresponding to the value of the visibility field and if uid is not among the values of that members field, remove the comment.
      • Removes that comment if the value of its uid field is among those of the fetched blocked field above.
      • Finds the profile that has a uid corresponding to that of the current comment, and removes that comment if the uid passed is among the values of blocked field.
      • If the comment has a visibility of followers fetch the followers field of the profile corresponding to the value of the uid field of that comment and if uid is not among these values or is not equal to the value of the uid field of the comment itself, remove the comment.
      • Append the value of the commentID field of all removed comments to removedComments.
      • Loop through all comments again, and remove all those who have a value for their reply_to field corresponding to a value inside of the removedComments array.
  • Filters out the posts, keeping only those having a value for their uid field that corresponds to that of the profileID field passed.
  • Sort all the posts by date in descending order of when they were posted based on the value of their posted_on field.
  • Adds a senderName and senderUsername field to each of the posts having a value equal to that of the name and username of the user who posted it identified by the value of its uid field.