neardevhub-bos
neardevhub-bos copied to clipboard
Moderation / trust & safety
Background
There are spamming posts on Devhub and we want to prevent these posts.
Requirements
- Requirement 1: Need a way to force people to comply with our Code of Conduct
- Requirement 2: Need a way for people to report a post & a mechanism for moderators to receive those
- Requirement 3: Need a way to moderate: Hide/delete a post
- Requirement 4: Need a way to ban specific users
- When I ban a user, it will:
- Remove all of their previous posts
- Prevent them from creating future posts
- When I ban a user, it will:
Technical Details
We will need to add these feature to smart contract, on SocialDB and the frontend.
For requirement 1, when user log on to the new version of DevHub, we can check if there is a marker set in SocialDB that he has accept the code of conduct. If not, a Code of Conduct dialog should pop up and ask the user to click accept the terms. The button will store the marker to SocialDB so the dialog won't popup next time. (Estimation: 1 day)
For requirement 2, their should be a new type of action added in smart contract, we can it report_post. Techincally it's similar to the implementation of like_post, and store post flagged by certain user at certain timestamp on smart contract. And instead of notification to the author, it notifies moderators, which is update all moderators SocialDB entry of notification. And also update notification type to display notification of "Post Reported" type properly on gateway. (Estimation: 3 days)
For requirement 3, on contract side this should be supported, mark a post to be hidden or deleted. I suggest to call this action delete_post. Only moderators are allowed to perform this action. When call delete_post
, It will set the newly introduced field post.deleted to true. Also update add_post, edit_post and like_post to not allow add comment, edit or like a deleted post. Also, delete_post will cross contract call the SocialDB contract to notify the author that his post is flagged.
On indexer, all post feeds or search result for frontend should filter deleted=false posts, so deleted posts won't appear in frontend.
On frontend, the top level deleted posts won't show up due to indexer has filter out these posts. Frontend should filter out non top level deleted posts, when rendering post comments, and if it's deleted, skip render it and hence itself and all its children are hidden. When rendering posts, it also show up icon for moderators to call delete_post. Also on frontend, once a deleted post type is accessed directly via id, it should display some empty placeholder saying "This post is deleted due to violation of the Code of Conduct". If a deleted post's child post is accessed directly via id, it can be displayed, so it won't affect non violation post link to be shared with others. Finally, update the notification item widget to display "Post Flagged" notification to the author on gateway's notification feed.
(Estimation: 1 week)
For requirement 4, on contract side add a ban_user function that delete all posts of the author, and store the user_id in a new UnorderedMap called blacklist. When a user try to perform add_post action, first check if he is in blacklist and prevent if so. On frontend side, at post editor page display a banner to the user if he is blacklist, and prevent him to use the post editor. (Estimation: 1 day)
Overall: 2 weeks and I will break down these to 4 separate tasks, each for one major requirement.
### Tasks
- [ ] https://github.com/near/neardevhub-widgets/issues/493
- [ ] https://github.com/near/neardevhub-widgets/issues/541
- [ ] https://github.com/near/neardevhub-widgets/issues/542