feat: add content reporting escalation workflow to ModerationModule#917
Open
Xaxxoo wants to merge 1 commit into
Open
feat: add content reporting escalation workflow to ModerationModule#917Xaxxoo wants to merge 1 commit into
Xaxxoo wants to merge 1 commit into
Conversation
…inafcode#876) Ensure reports are never left unattended in PENDING status by introducing automatic assignment and SLA-based escalation. Changes: - ContentReport entity: add assignedModerator (ManyToOne User), assignedModeratorId (indexed FK), and escalatedAt (timestamp) fields - ReportAssignmentService (src/moderation/assignment/report-assignment.service.ts): * assignReport() — round-robin assigns new reports across the active moderator pool and sends an IN_APP notification to the assignee * escalateReport() — re-assigns to a random admin, sets escalatedAt, and sends an URGENT IN_APP notification * escalateOverdueReports() — @Cron every 5 min; finds PENDING/UNDER_REVIEW reports older than MODERATION_SLA_HOURS (default 24 h) without escalatedAt and escalates them * Notification failures are swallowed so they never block assignment - ContentReportingService: calls assignReport() after a report is queued - ModerationModule: registers ReportAssignmentService, imports User entity and NotificationsModule - 11 unit tests covering round-robin distribution, escalation, overdue sweep, empty moderator/admin pools, and notification failure isolation
|
@Xaxxoo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Great job so far There’s just one blocker — the workflow is failing. Could you take a look and fix it so all checks pass? Happy to review again once that’s done. |
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.
Closes #876
Summary
Adds automatic report assignment and SLA-based escalation so reports are never left unattended in
PENDINGstatus indefinitely.Modified files:
src/moderation/reports/content-report.entity.tsassignedModerator(ManyToOne),assignedModeratorId(indexed FK),escalatedAt(timestamp)src/moderation/reports/content-reporting.service.tsassignReport()immediately after a report is queuedsrc/moderation/moderation.module.tsReportAssignmentService, importUserentity andNotificationsModuleNew files:
src/moderation/assignment/report-assignment.service.tssrc/moderation/assignment/report-assignment.service.spec.tsHow it works:
ContentReportingServicecallsReportAssignmentService.assignReport().assignReport()loads the active moderator pool (users with themoderatorrole, sorted by ID for determinism) and picks the next one via a round-robin cursor. The report is moved toUNDER_REVIEWand the moderator receives anIN_APPnotification.@Cron(EVERY_5_MINUTES)task (escalateOverdueReports) scans forPENDING/UNDER_REVIEWreports whosecreatedAtexceedsMODERATION_SLA_HOURS(default 24 h, configurable via env) and that have not yet been escalated (escalatedAt IS NULL).escalateReport()reassigns to a randomly-chosen admin, setsescalatedAt, and sends anURGENTpriority notification.Test plan
assignReportassigns to the first moderator in the poolescalateReportsetsassignedModeratorIdto an admin and setsescalatedAtURGENTpriorityescalateOverdueReportsescalates overdue reports returned by the repoescalateOverdueReportsis a no-op when no overdue reports existnpm test)