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 theuid
passed and fetches a list of all values inside of thefollowing
andblocked
fields. - Finds the record from the
posts
collection having apostID
corresponding to the one passed [404]. - Finds the
collection
from the foundprofile
with a value for itscollectionID
field corresponding to the one passed [404]. - Ensures that the record found does not have a value for its
visibility
field set tonone
[403]. - If the record does not have a
visibility
ofnone
,followers
orpublic
, fetch themembers
field of theAccessGroup
corresponding to the value of thevisibility
field and ensures thatuid
is among the values of thatmembers
field [403]. - Ensures that that record’s
uid
field does not equal to a value among those of the fetchedblocked
field above [403]. - Ensures that the
profile
that has auid
corresponding to that of the currentpost
record does not contain a value corresponding to theuid
passed in itsblocked
field [403]. - 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
[403]. - Else, if the record does not have a value for its
groupID
field, and has a value offollowers
for its visibility field check ifuid
is among the values of thefollowing
field or if it is equal to theuid
of thepost
itself [403]. - If
save
has a value oftrue
, ensure thatpostID
is not already a value among theposts
field of the foundcollection
, else, ifsave
has a value offalse
, ensure thatpostID
is a value among theposts
field of the foundcollection
[403]. - Appends and saves the value of
postID
to theposts
field of the foundcollection
from theprofile
of theuser
whoseuid
corresponds to the one passed ifsave
is set totrue
, else removespostID
from the values of that field.