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
profilecorresponding to theuidpassed and fetches a list of all values inside of thefollowingandblockedfields. - Finds the record from the
postscollection having apostIDcorresponding to the one passed [404]. - Ensures that the record found does not have a value for its
visibilityfield set tonone[403]. - If the record does not have a
visibilityofnone,followersorpublic, fetch themembersfield of theAccessGroupcorresponding to the value of thevisibilityfield and ensures thatuidis among the values of thatmembersfield [403]. - If the record has a value for its
groupIDfield, find thegroupcorresponding to thatgroupIDand check ifuidis a value among thatgroup’smembersfield with astatusofaccepted[403]. - Ensures that the record’s
uidfield does not equal to a value among those of the fetchedblockedfield above [403]. - Ensures that the
profilethat has auidcorresponding to that of the record does not contain a value corresponding to theuidpassed in itsblockedfield [403]. - Else, if the record does not have a value for its
groupIDfield, and has a value offollowersfor its visibility field check ifuidis among the values of thefollowingfield or if it is equal to theuidof thepostitself [403]. - Checks that there is a
commentcorresponding to the value of thecommentIDfield passed inside of thatpost’scommentsfield [404]. - Ensures that the found
commenthas the sameuidas that passed [403]. - Validates the value of the
visibilityfield passed to make sure that its value is eitherpublic,followers,noneor one among theaccessIDs found in theaccess_groupsfield in the record corresponding to that of theuidpassed from theprofilescollection [400]. - Generates a
timestampfor the current date/time. - Updates and saves the object inside of that
post’scommentsfield corresponding to thecommentIDpassed with the values of thecommentand/orvisibilityfields passed, along with the value of the generatedtimestampfor themodified_onfield.