feat: allow community admins to flag users as spam#3522
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a community-level moderation flow that lets community admins flag/ban users for spam review, hides flagged users’ content from non-admins, and extends the superadmin spam dashboard with community-report context and filters.
Changes:
- Introduces
CommunityModerationReportmodel/API/hooks + activity items for report created/retracted. - Enforces community bans across mutating API routes and hides flagged users’ discussions/comments for non-admins.
- Enhances superadmin spam user dashboard (new filters, URL-sync, community report details) and adds admin UI to ban/unban users.
Reviewed changes
Copilot reviewed 74 out of 74 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/moderationReasons.ts | Adds centralized labels/helpers for moderation report reasons. |
| utils/activity/titles/pub.tsx | Extends activity title types to support moderation items. |
| utils/activity/titles/community.ts | Extends accepted activity items for community moderation report events. |
| types/spam.ts | Adds moderation report types + spam dashboard query extensions and report DTO type. |
| types/pubQuery.ts | Adds communityId option for pub fetch options. |
| types/pub.ts | Refactors pub discussion/thread comment types to embed moderation/spam info on authors. |
| types/activity/index.ts | Exports moderation-report activity item types and includes them in insertable items. |
| types/activity/filters.ts | Adds moderation activity filter. |
| types/activity/communityModerationReport.ts | Defines activity item payload/kinds for report created/retracted. |
| server/utils/slack.ts | Removes old spam/slack notification helpers (moved to new module). |
| server/utils/rateLimiter.ts | Adds a per-user sliding-window rate limiter utility. |
| server/utils/queryHelpers/util.ts | Adds moderation report include to author/thread includes; improves visibility sanitizer typing. |
| server/utils/queryHelpers/reviewGet.ts | Passes communityId-aware includes when fetching review threads. |
| server/utils/queryHelpers/pubSanitize.ts | Narrows discussion visibility typing in sanitize helpers. |
| server/utils/queryHelpers/pubOptions.ts | Threads communityId through author/thread includes. |
| server/utils/queryHelpers/pubGet.ts | Ensures communityId is passed into pub options for moderation data inclusion. |
| server/utils/queryHelpers/discussionsSanitize.ts | Hides content for spam/flagged authors unless admin. |
| server/utils/email/spam.ts | Removes legacy spam email helpers (replaced by new notifications module). |
| server/utils/email/index.ts | Stops exporting removed spam email module. |
| server/user/model.ts | Adds communityModerationReports association on User. |
| server/threadComment/model.ts | Adds thread association for traversing comment → thread → discussion → pub. |
| server/threadComment/api.ts | Blocks reported users from creating thread comments in the community. |
| server/thread/model.ts | Adds discussion association for traversing thread → discussion. |
| server/spamTag/userDashboard.ts | Adds hasCommunityReport + spamFieldsFilter, and returns community reports per user. |
| server/spamTag/notifications/slack.ts | New Slack notification module (spam + community flag events). |
| server/spamTag/notifications/shared.ts | Shared URL/reason helpers for spam/flag Slack/email notifications. |
| server/spamTag/notifications/index.ts | New notification dispatcher supporting community flag lifecycle events. |
| server/spamTag/notifications/email.ts | New email notification module (dev + reporter + user emails). |
| server/spamTag/notifications.ts | Removes old notification module (replaced by folder-based implementation). |
| server/spamTag/api.ts | Adds superadmin guard for marking admins as spam; triggers reporter resolution notifications; adds new query params. |
| server/server.ts | Registers communityModerationGuard middleware. |
| server/routes/superAdminDashboard.tsx | Adds URL-driven filtering/sorting parameters for spam users dashboard. |
| server/routes/dashboardMembers.tsx | Includes banned users data for community members dashboard. |
| server/routes/dashboardActivity.tsx | Excludes moderation activity items for non-community-admins. |
| server/pub/permissions.ts | Blocks community-banned users from creating pubs. |
| server/pub/api.ts | Removes unused Express type import. |
| server/models.ts | Registers CommunityModerationReport model with Sequelize. |
| server/middleware/communityModerationGuard.ts | New middleware to block community-banned users from mutating community APIs. |
| server/hooks.ts | Registers community moderation report hooks. |
| server/discussion/permissions.ts | Minor refactor in create permission retrieval. |
| server/discussion/api.ts | Validates pubId on discussion creation. |
| server/communityModerationReport/queries.ts | Adds report CRUD + reporter-resolution notification logic. |
| server/communityModerationReport/model.ts | Adds Sequelize model definition for moderation reports. |
| server/communityModerationReport/hooks.ts | Emits activity items when reports are created/retracted. |
| server/communityModerationReport/api.ts | Adds API endpoints for creating/retracting/listing reports with permission checks. |
| server/communityModerationReport/tests/api.test.ts | Adds API tests for report creation/retraction and enforcement. |
| server/apiRoutes.ts | Registers community moderation report router. |
| server/activityItem/queries.ts | Adds activity item creation helpers for moderation report events and source resolution. |
| server/activityItem/fetch.ts | Adds moderation filter definition + excludeKinds support + association resolution for moderation items. |
| server/activityItem/api.ts | Excludes moderation items for non-community-admins. |
| server/activityItem/tests/fetch.test.ts | Adds fetch coverage for moderation report activity items. |
| infra/docker-compose.dev.yml | Improves dev healthcheck settings (retries/start_period). |
| client/utils/activity/renderers/moderation.tsx | Adds UI renderer for moderation report activity items. |
| client/utils/activity/renderers/index.ts | Registers moderation activity renderers. |
| client/containers/SuperAdminDashboard/UserSpam/userSpamEntry.scss | Adds styling for new report/discussion popovers and report chips. |
| client/containers/SuperAdminDashboard/UserSpam/userSpam.scss | Refactors spam users dashboard toolbar and filter popovers styling. |
| client/containers/SuperAdminDashboard/UserSpam/useSpamUsers.ts | Sends hasCommunityReport with spam user query requests. |
| client/containers/SuperAdminDashboard/UserSpam/types.ts | Extends SpamUser type to include communityReports. |
| client/containers/SuperAdminDashboard/UserSpam/filters.ts | Adds “Flagged” filter using hasCommunityReport. |
| client/containers/SuperAdminDashboard/UserSpam/UserSpamEntry.tsx | Displays community report info, popovers, and refactors actions UI. |
| client/containers/SuperAdminDashboard/UserSpam/UserSpam.tsx | Adds URL-synced filters (dates, activity count, spam field reasons) and toolbar UI. |
| client/containers/Pub/PubDocument/PubDiscussions/Discussion/threadComment.scss | Adds flagged/banned styling and button styling for flag actions. |
| client/containers/Pub/PubDocument/PubDiscussions/Discussion/discussion.scss | Formatting tweaks and minor layout adjustments. |
| client/containers/Pub/PubDocument/PubDiscussions/Discussion/ThreadComment.tsx | Adds Ban/Unban UI, flagged state display, and updates spam/flag local state handling. |
| client/containers/Pub/PubDocument/PubDiscussions/Discussion/ManageTools.tsx | Removes discussion-level spam status menu from manage tools. |
| client/containers/Pub/PubDocument/PubDiscussions/Discussion/DiscussionInput.tsx | Makes thread comment append tolerant of missing comments array. |
| client/containers/Pub/PubDocument/PubDiscussions/Discussion/Discussion.tsx | Adjusts spam author detection to use author spamTag info; removes old spam banner handling. |
| client/containers/DashboardMembers/dashboardMembers.scss | Adds styles for “Banned Users” tab list. |
| client/containers/DashboardMembers/DashboardMembers.tsx | Adds “Banned Users” tab and unban action. |
| client/containers/DashboardActivity/ActivityFilters.tsx | Shows moderation activity filter only for community admins. |
| client/components/index.ts | Exports new FlagUserDialog component. |
| client/components/SpamStatusMenu/SpamStatusMenu.tsx | Adds CSS class for button styling alignment with new UI. |
| client/components/FlagUserDialog/FlagUserDialog.tsx | Adds dialog for admins to ban a user with reason/details. |
| biome.jsonc | Enables CSS formatter with tab indentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
client/containers/SuperAdminDashboard/UserSpam/UserSpamEntry.tsx
Outdated
Show resolved
Hide resolved
client/containers/Pub/PubDocument/PubDiscussions/Discussion/ThreadComment.tsx
Outdated
Show resolved
Hide resolved
client/containers/SuperAdminDashboard/UserSpam/UserSpamEntry.tsx
Outdated
Show resolved
Hide resolved
client/containers/SuperAdminDashboard/UserSpam/UserSpamEntry.tsx
Outdated
Show resolved
Hide resolved
3mcd
approved these changes
Mar 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue(s) Resolved
Resolves #3504
What does it do
This PR allows community admins to ban users from their community. They can do this, at the moment, only from discussions.
When a user is banned, it will look like such for the admin (and us)
Community admins can then see the users they have banned in the Members tab:
Banning a user will generate an activity item
When a user is banned,
the banned user
the community admin who banned them,
the dev team
When dev team marks the user as spam
when dev team marks user as confirmed not spam
Screenshots (if applicable)
Optional
Notes/Context/Gotchas
Supporting Docs