Skip to content

39 moderation panel#77

Merged
sametekinpolat merged 7 commits intodevelopmentfrom
39-moderation-panel
May 3, 2026
Merged

39 moderation panel#77
sametekinpolat merged 7 commits intodevelopmentfrom
39-moderation-panel

Conversation

@sametekinpolat
Copy link
Copy Markdown
Owner

closes #39 #76 #75 #74

sametekinpolat and others added 7 commits May 3, 2026 21:05
…39)

- Extend ModActionType enum with 13 new governance and audit action types
- Add CommunityStatus enum (ACTIVE, CLOSED) for community lifecycle
- Add status field to Community model (default ACTIVE)
- Add performance indexes on Report, CommunityRestriction, ModLog, Post, Comment
- Create src/lib/moderation/permissions.ts with getModerationContext()
  helper that resolves global mod, owner, and community mod flags in one
  parallel DB round-trip, eliminating per-permission N+1 queries
- Create migration SQL for all schema changes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reports: resolveReportAction, dismissReportAction
Content: removePostAction, removeCommentAction, pinPostAction
Restrictions: muteUserAction, banUserAction, revokeRestrictionAction
Settings: deleteRuleAction
Governance: assignModeratorAction, removeModeratorAction,
  updateModeratorPermissionsAction, closeCommunityAction,
  reopenCommunityAction, transferOwnershipAction, deleteCommunityAction

All actions:
- Gate on getModerationContext() for scope-aware permission checks
- Write a ModLog entry inside the same transaction as the data mutation
- Prevent self-restriction and owner lock-out edge cases
- Return structured error/success for client feedback

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pages:
- /moderation — global mod panel listing all communities with pending
  report counts; guards to GlobalModerator record server-side
- /communities/[name]/moderation — community-scoped panel;
  guards via getModerationContext, redirects non-mods

Components (src/components/moderation/):
- panel.tsx — tabbed shell with role-context header and badge on Reports
- reports-tab.tsx — resolve/dismiss with status filter, optimistic update
- posts-tab.tsx — remove + pin/unpin with per-row reason input
- comments-tab.tsx — remove with reason input, all/removed filter
- restrictions-tab.tsx — add mute/ban form + active restriction list with
  revoke; duplicate-restriction check runs server-side
- mod-log-tab.tsx — full audit trail with action-type filter
- settings-tab.tsx — add/reorder/delete community rules
- governance-tab.tsx — moderator roster (assign, update perms, remove),
  community close/reopen, transfer ownership, delete community;
  owner-only danger-zone clearly separated from shared mod controls

Community page:
- Wire getModerationContext() to replace duplicated per-permission queries
- Propagate hasModerationAccess prop down to show "Moderation Panel" link
  in sidebar for any user with moderation access (global mod, owner, mod)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… and panel

- Change Prisma import from type-only to value import so Prisma.DbNull
  can be used as a runtime value for nullable JSON fields in ModLog.details
- Use `satisfies` constraint + explicit `as Tab` casts in panel tab array
  to satisfy the { id: Tab } narrowing requirement

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sametekinpolat sametekinpolat merged commit 3394ca8 into development May 3, 2026
1 check passed
@sametekinpolat sametekinpolat deleted the 39-moderation-panel branch May 3, 2026 18:51
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.

1 participant