Moderation & Content Reporting
Relevant source files
The following files were used as context for generating this wiki page:
- app/Filament/Pages/ModerationDashboard.php
- app/Actions/Moderation/ShadowbanUserAction.php
- app/Actions/Reports/ReportContentAction.php
- app/Models/ModerationLog.php
- tests/Feature/Livewire/InlinePostModerationTest.php
- tests/Feature/Actions/CreateModerationLogActionTest.php
- resources/views/livewire/moderation/inline-post-moderation.blade.php
- app/Actions/Moderation/ApprovePostAction.php
- app/Actions/Moderation/CreateModerationLogAction.php
- tests/Feature/Policies/ModerationPolicyTest.php
The Moderation & Content Reporting system in RateGuru provides a multi-layered framework for maintaining community standards. It encompasses user-initiated reporting, administrative dashboards for oversight, and granular moderation actions such as approving, rejecting, hiding, or restoring content, as well as managing user statuses through shadowbanning.
The system is built using Laravel Actions for business logic, Filament for administrative interfaces, and Livewire for real-time frontend moderation components. This ensures that moderation tasks are both accessible to authorized personnel and strictly governed by security policies.
Moderation Architecture
The moderation architecture is centered around specialized Actions that encapsulate business rules and Policies that enforce authorization. Moderation activities are tracked via a dedicated logging system to ensure accountability.
Core Moderation Components
| Component | Description |
|---|---|
| ModerationDashboard | A Filament-based administrative page providing a summary of pending posts, reports, and suspicious users. |
| InlinePostModeration | A Livewire component allowing moderators to take action directly from the post feed or show pages. |
| Moderation Actions | Classes like ApprovePostAction and ShadowbanUserAction that handle specific state transitions and logging. |
| ModerationLog | A database model that records every action taken by a moderator, including the target, action type, and reason. |
Sources: app/Filament/Pages/ModerationDashboard.php, app/Models/ModerationLog.php, tests/Feature/Livewire/InlinePostModerationTest.php:9-25
Data Flow: Content Moderation
This diagram illustrates the lifecycle of a post moderation action initiated from the UI kit or post feed.
Content Reporting System
The reporting system allows users to flag content (Posts, Comments, or Users) that violates community guidelines.
Reporting Logic
Reports are processed through the ReportContentAction. This action performs several critical checks before persisting a report:
- Target Validation: Ensures the target (e.g., Post or Comment) exists and is visible.
- Duplicate Prevention: Prevents a user from reporting the same content multiple times.
- Rate Limiting: Restricts the frequency of reports to prevent spam.
Sources: app/Actions/Reports/ReportContentAction.php, tests/Feature/Livewire/ReportModalTest.php:48-65
Report Categories
Users must select a reason when submitting a report. Supported reasons include:
- Spam
- Offensive
- Fake
- Copyright
- Wrong category (Not food/Wrong Category)
- Other
Sources: lang/en/ui.php:116-123, tests/Feature/Livewire/ReportModalTest.php:225-235
Administrative Tools
Moderation Dashboard
The dashboard serves as the central hub for administrative oversight. It features four primary summary widgets:
- Pending Posts: New content awaiting initial approval.
- Reported Posts: Published posts flagged by users.
- Reported Comments: Comments flagged by users.
- Suspicious Users: Users with high report counts or existing status restrictions.
Sources: app/Filament/Pages/ModerationDashboard.php, tests/Feature/Filament/ModerationDashboardTest.php:57-118
User Management & Shadowbanning
Administrators can restrict user accounts without immediate deletion. The ShadowbanUserAction updates a user's status to Shadowbanned, which typically limits their visibility or interaction capabilities while the action is logged for audit trails.
Security & Permissions
Access to moderation features is strictly controlled via Laravel Policies.
| Ability | Role Required | Description |
|---|---|---|
moderate-content | Moderator, Admin | Ability to approve, reject, hide, or restore posts and comments. |
ban-user | Admin | High-level ability to change user statuses or ban accounts. |
report | Authenticated User | Ability to flag content (cannot report own content). |
Sources: tests/Feature/Policies/ModerationPolicyTest.php:19-45, tests/Feature/Policies/PostPolicyTest.php:106-112
Moderation Logging Schema
Every administrative action is stored in the moderation_logs table for audit purposes.
| Field | Type | Description |
|---|---|---|
moderator_id | Foreign Key | The ID of the user who performed the action. |
action | Enum | Type of action (e.g., approve_post, hide_post, shadowban). |
target_type | String | The model class of the target content. |
target_id | Integer | The ID of the target content. |
reason | Text | Optional note provided by the moderator. |
metadata | JSON | Additional context (e.g., source of action). |
Sources: app/Models/ModerationLog.php, app/Actions/Moderation/CreateModerationLogAction.php:15-30, tests/Feature/Actions/CreateModerationLogActionTest.php:10-25
Conclusion
The Moderation & Content Reporting module provides a robust, logged, and secure environment for platform governance. By separating the logic into discrete Actions and enforcing strict Policies, the system ensures that community standards are upheld while maintaining a clear audit trail of all administrative interventions.