-
-
Notifications
You must be signed in to change notification settings - Fork 428
Premoderation #1966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Premoderation #1966
Conversation
Migrate golangci-lint to v2 and update Go version (umputun#1965)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a premoderation feature for comments with three configurable strategies: "none" (no premoderation), "first" (premoderate only the first comment from a user), and "all" (premoderate every comment). The feature allows admins to approve comments before they become visible to regular users.
- Adds premoderation logic on both frontend and backend with an admin approval UI
- Introduces filtering of unapproved comments for non-admin users
- Implements approval workflow that can approve single or multiple comments based on strategy
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
backend/app/store/comment.go |
Adds Approved boolean field to Comment struct |
backend/app/store/service/service.go |
Implements ApproveComments method supporting single and bulk approval |
backend/app/rest/api/rest.go |
Defines Premoderation type and factory function |
backend/app/rest/api/rest_public.go |
Filters unapproved comments for non-admin users in public endpoints |
backend/app/rest/api/rest_private.go |
Handles premoderation logic during comment creation |
backend/app/rest/api/admin.go |
Adds admin endpoint for approving comments |
backend/app/main.go |
Adds CLI flag for premoderation configuration |
backend/app/cmd/cmd.go |
Passes premoderation option through command structure |
backend/app/cmd/server.go |
Initializes server with premoderation strategy |
backend/app/rest/httperrors.go |
Adds error code for premoderation failures |
frontend/apps/remark42/app/common/types.ts |
Adds approved field to Comment interface |
frontend/apps/remark42/app/common/api.ts |
Adds approveComment API function |
frontend/apps/remark42/app/store/comments/actions.ts |
Adds approveComment Redux action |
frontend/apps/remark42/app/components/comment/comment.tsx |
Adds UI logic and styling for unapproved comments |
frontend/apps/remark42/app/components/comment/comment-actions.tsx |
Adds approve/disapprove button |
frontend/apps/remark42/app/components/comment/connected-comment.tsx |
Connects approve action to component |
backend/app/rest/api/rest_public_test.go |
Updates tests to handle approved field in responses |
backend/app/rest/api/admin_test.go |
Adds tests for comment approval functionality |
backend/app/store/service/service_test.go |
Adds test for ApproveComments service method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| (id: Comment['id'], text: string, approved: boolean): StoreAction<Promise<void>> => | ||
| async (dispatch) => { | ||
| const comment = await api.approveComment({ id, text, approved }); | ||
| dispatch(patchComment({ ...comment, approved: comment.approved })); |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spread operator { ...comment, approved: comment.approved } is redundant since comment already contains the approved field. Consider simplifying to just dispatch(patchComment(comment)).
| dispatch(patchComment({ ...comment, approved: comment.approved })); | |
| dispatch(patchComment(comment)); |
| comment.Approved = true | ||
| return comment, nil | ||
| } | ||
| } |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing fallback case: If PremoderationFirst is active and the user has previous comments but none are approved, the function doesn't explicitly set comment.Approved = false before falling through. The comment will remain with its default zero value, but this should be made explicit for clarity. Add comment.Approved = false after the loop (line 214).
| } | |
| } | |
| // Explicitly set Approved to false if no previous comment was approved | |
| comment.Approved = false |
frontend/apps/remark42/app/components/comment/comment-actions.tsx
Outdated
Show resolved
Hide resolved
|
@fedmag Hi, is it possible to add modes "with links" or/and "with images"? |
Hello, this is a first draft for the addition of pre-moderation.
It uses an "approved" flag to define if a comment should be visible to non-admin users.
Only admins can approve/disapprove comments.
There are 3 modes:
In the UI, I added a red border for unapproved comments so that they are easy to spot:

I'd assume this solution is not desirable, but I did not have any other idea.