Link Search Menu Expand Document

Post Save

/api/v2/feed/post/save

Post

posts

profiles

groups

jwt


Purpose

To allow a user to [un]save a post.

Body Content [input]

{
    uid: string,
    postID: string,
    collectionID: string,
    save: bool
}

Returns if valid [output]

{
    message: string,
    error: 0
}

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.
  • Finds the record from the posts collection having a postID corresponding to the one passed [404].
  • Finds the collection from the found profile with a value for its collectionID field corresponding to the one passed [404].
  • Ensures that the record found does not have a value for its visibility field set to none [403].
  • 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 ensures that uid is among the values of that members field [403].
  • Ensures that that record’s uid field does not equal to a value among those of the fetched blocked field above [403].
  • Ensures that the profile that has a uid corresponding to that of the current post record does not contain a value corresponding to the uid passed in its blocked field [403].
  • 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 [403].
  • Else, if the record does not have a value for its groupID field, and has a value of followers for its visibility field check if uid is among the values of the following field or if it is equal to the uid of the post itself [403].
  • If save has a value of true, ensure that postID is not already a value among the posts field of the found collection, else, if save has a value of false, ensure that postID is a value among the posts field of the found collection [403].
  • Appends and saves the value of postID to the posts field of the found collection from the profile of the user whose uid corresponds to the one passed if save is set to true, else removes postID from the values of that field.