Reports & Content Moderation
The Ever Works template includes a content reporting and moderation system that enables users to flag inappropriate content and administrators to take action on reported items and comments.
Architecture
Content Types
The system supports reporting two content types:
enum ReportContentType {
ITEM = 'item',
COMMENT = 'comment',
}
ModerationService
Located at lib/services/moderation.service.ts, the service provides moderation actions:
Content Owner Resolution
async function getContentOwner(
contentType: ReportContentTypeValues,
contentId: string
): Promise<ContentOwnerResult>;
// Returns: { success: boolean, userId?: string, error?: string }
Resolves the author of reported content by looking up comments via getCommentById() or items via ItemRepository.findById().
Moderation Actions
| Action | Description | Effect |
|---|---|---|
| Remove content | Delete the reported item or comment | Content removed, history recorded |
| Warn user | Increment warning count | Warning counter incremented |
| Suspend user | Temporarily suspend account | Account access restricted |
| Ban user | Permanently ban account | Account permanently restricted |
| Dismiss report | Mark report as resolved without action | Report closed |
Action Implementation
Each action creates a moderation history entry and may trigger email notifications:
// Example: Remove content
async function removeContent(
contentType: ReportContentTypeValues,
contentId: string,
reportId: string,
adminId: string
): Promise<ModerationResult>;
The service delegates to:
deleteComment()-- For comment removalItemRepository-- For item removalcreateModerationHistory()-- For audit trailincrementWarningCount()-- For user warningssuspendUserQuery()/banUserQuery()-- For account actionsEmailNotificationService-- For user notification emails
Admin Hook
import { useAdminReports } from '@/hooks/use-admin-reports';
const {
reports, // Report[]
total, page, totalPages,
isLoading, isSubmitting,
resolveReport, // (id, action, reason?) => Promise<boolean>
dismissReport, // (id, reason?) => Promise<boolean>
deleteReport, // (id) => Promise<boolean>
refetch, refreshData,
} = useAdminReports({ page: 1, limit: 10 });
Moderation Workflow
- User reports content -- Selects a reason and submits via the report API
- Admin notification --
NotificationService.createItemReportedNotification()orcreateCommentReportedNotification()alerts admins - Admin reviews -- Views report details in the admin dashboard
- Admin takes action -- Chooses from: remove content, warn user, suspend, ban, or dismiss
- History recorded --
createModerationHistory()logs the action with admin ID, timestamp, and reason - User notified -- Email notification sent to the content owner about the action taken
Moderation Actions Enum
enum ModerationAction {
REMOVE_CONTENT = 'remove_content',
WARN_USER = 'warn_user',
SUSPEND_USER = 'suspend_user',
BAN_USER = 'ban_user',
DISMISS = 'dismiss',
}
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/reports | Submit a new report |
| GET | /api/admin/reports | List reports (admin, paginated) |
| POST | /api/admin/reports/:id/resolve | Resolve a report with action |
| POST | /api/admin/reports/:id/dismiss | Dismiss a report |
| DELETE | /api/admin/reports/:id | Delete a report |
Related Documentation
- Notification System -- How report notifications are delivered
- Voting & Comments -- Comment system that can be reported