Skip to content

feat: allow community admins to flag users as spam#3522

Merged
tefkah merged 17 commits intomainfrom
tfk/community-admin-flag
Mar 12, 2026
Merged

feat: allow community admins to flag users as spam#3522
tefkah merged 17 commits intomainfrom
tfk/community-admin-flag

Conversation

@tefkah
Copy link
Member

@tefkah tefkah commented Mar 4, 2026

  • feat: allow community admins to flag users
  • fix: flagging, and big improvements to userdash

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.

image image

When a user is banned, it will look like such for the admin (and us)

image

Community admins can then see the users they have banned in the Members tab:

image

Banning a user will generate an activity item

image

When a user is banned,

the banned user

  • cannot do any mutating requests on the community anymore, therefore cannot interact with it
  • The banned user's comments are hidden from all non community admin/superadmin users
  • The banned user will NOT be notified of this
  • The banned user can still log in

the community admin who banned them,

  • will receive a notification that the dev team will take a look
  • can unban the user at any time

the dev team

  • will receive a notifciation in slack and email that the user is banned/unbanned

When dev team marks the user as spam

  • user is spam as normal, all comments are hidden, they are logged out
  • user will receive email they are banned
  • community admin who banned user will receive confirmation email

when dev team marks user as confirmed not spam

  • banned user will not receive email
  • banned user still cannot interact in banned community, comments are still hidden
  • community admin who banned them will receive an email saying "hey we did'nt think this user is spam but they are still banned thanks anyway"

Screenshots (if applicable)

Optional

Notes/Context/Gotchas

Supporting Docs

@tefkah tefkah marked this pull request as ready for review March 9, 2026 20:40
@tefkah tefkah requested review from 3mcd and Copilot March 9, 2026 20:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CommunityModerationReport model/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.

@tefkah tefkah merged commit 48af493 into main Mar 12, 2026
1 check passed
@tefkah tefkah deleted the tfk/community-admin-flag branch March 12, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admins can flag users for spam review

3 participants