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
profile
corresponding to theuid
passed and fetches a list of all values inside of thefollowing
andblocked
fields. - Finds all records from the
posts
collection. - Loops through each of these
post
records and:- Removes that record if it has a
visibility
set tonone
. - If the record does not have a
visibility
ofnone
,followers
orpublic
, fetch themembers
field of theAccessGroup
corresponding to the value of thevisibility
field and ifuid
is not among the values of thatmembers
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 fetchedblocked
field above. - Finds the
profile
that has auid
corresponding to that of the currentpost
record, and removes that record if theblocked
field contains theuid
passed. - If the record has a value for its
groupID
field, find thegroup
corresponding to thatgroupID
and check ifuid
is a value among thatgroup
’smembers
field with astatus
ofaccepted
. If that is not the case and if thegroup
has a value ofprivate
for itsprivacy
field, remove that record. - Loop through each of the
comment
of thecomments
field of that record and:- Create a new data structure
removedComments
for thecommentID
s of removedcomment
s. - Remove that
comment
if it has avisibility
set tonone
. - If the
comment
does not have avisibility
ofnone
,followers
orpublic
, fetch themembers
field of theAccessGroup
corresponding to the value of thevisibility
field and ifuid
is not among the values of thatmembers
field, remove thecomment
. - Removes that
comment
if the value of itsuid
field is among those of the fetchedblocked
field above. - Finds the
profile
that has auid
corresponding to that of the currentcomment
, and removes thatcomment
if theuid
passed is among the values ofblocked
field. - If the
comment
has avisibility
offollowers
fetch thefollowers
field of theprofile
corresponding to the value of theuid
field of thatcomment
and ifuid
is not among these values or is not equal to the value of theuid
field of thecomment
itself, remove thecomment
. - Append the value of the
commentID
field of all removedcomment
s toremovedComments
. - Loop through all
comment
s again, and remove all those who have a value for theirreply_to
field corresponding to a value inside of theremovedComments
array.
- Create a new data structure
- Removes that record if it has a
- Finds the
post
corresponding to the value of thepostID
field passed [404]. - Adds a
senderName
andsenderUsername
field to thepost
having a value equal to that of thename
andusername
of theuser
who posted it identified by the value of itsuid
field. - Adds a
groupName
field to thepost
corresponding to thename
of thegroup
if it has a value for itsgroupID
field.