Link Search Menu Expand Document

Fetch User

/api/v2/highlight/fetch/user

Post

stories

profiles

jwt

pgn


Purpose

To allow a user to fetch all related stories from highlights he/she is allowed to access for one specific user.

Body Content [input]

{
    uid: string,
    profileID: 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 profile corresponding to the uid passed and fetches a list of all values inside of the following and blocked fields.
  • Creates a new data structure: allowedStories.
  • Find all records from the profiles collection with a uid field corresponding to the value of the profileID field passed.
  • Loops through these records and:
    • Jump to the next value if the uid passed is a value included in the blocked field of the current record or if its uid is a value among the blocked field obtained above.
    • Jump to the next value unless the account_type is set to public or if the record contains the passed uid in its followers field.
    • Loop through each highlight in the highlights field, and:
      • Remove the highlight if it has a visibility of none, or if it is set to followers and the passed uid is not in the profile of the current user’s followers field. If the highlight has a visibility other than public, find the AccessGroup with the value corresponding to visibility for its accessID field and remove that highlight if uid is not among the values of that AccessGroup’s members field.
    • Append all the values from the storiesID field of the highlight field to the allowedStories data structure while guaranteeing that the data is always unique.
  • Finds all records from the stories collection having a value for their storyID field corresponding to one among those in the allowedStories list.
  • Loops through each of these story records and:
    • Skip everything that follows if the record’s uid has a value equal to the one passed.
    • 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.
    • 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 story record, and removes that record if the blocked field contains the uid passed.
    • Else, if the record has a value of followers for its visibility field, check if uid is among the values of the following field. If that is not the case, remove that record.
    • Remove the views field of that story record.