Comment Edit
/api/v2/feed/comment/edit
Post
posts
profiles
groups
jwt
Purpose
To allow a user to edit one of his/her existing comments on a post that he/she is allowed to comment on.
Body Content [input]
{
uid: string,
postID: string,
commentID: string,
comment: string,
visibility: string
}
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]. - 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]. - 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]. - Ensures that the 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 record does not contain a value corresponding to theuid
passed in itsblocked
field [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]. - Checks that there is a
comment
corresponding to the value of thecommentID
field passed inside of thatpost
’scomments
field [404]. - Ensures that the found
comment
has the sameuid
as that passed [403]. - Validates the value of the
visibility
field passed to make sure that its value is eitherpublic
,followers
,none
or one among theaccessID
s found in theaccess_groups
field in the record corresponding to that of theuid
passed from theprofiles
collection [400]. - Generates a
timestamp
for the current date/time. - Updates and saves the object inside of that
post
’scomments
field corresponding to thecommentID
passed with the values of thecomment
and/orvisibility
fields passed, along with the value of the generatedtimestamp
for themodified_on
field.