@atproto/ozone 0.1.173 → 0.1.174
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +40 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/moderation/emitEvent.d.ts.map +1 -1
- package/dist/api/moderation/emitEvent.js +31 -0
- package/dist/api/moderation/emitEvent.js.map +1 -1
- package/dist/api/queue/assignModerator.d.ts +4 -0
- package/dist/api/queue/assignModerator.d.ts.map +1 -0
- package/dist/api/queue/assignModerator.js +28 -0
- package/dist/api/queue/assignModerator.js.map +1 -0
- package/dist/api/queue/createQueue.d.ts +4 -0
- package/dist/api/queue/createQueue.d.ts.map +1 -0
- package/dist/api/queue/createQueue.js +44 -0
- package/dist/api/queue/createQueue.js.map +1 -0
- package/dist/api/queue/deleteQueue.d.ts +4 -0
- package/dist/api/queue/deleteQueue.d.ts.map +1 -0
- package/dist/api/queue/deleteQueue.js +40 -0
- package/dist/api/queue/deleteQueue.js.map +1 -0
- package/dist/api/queue/getAssignments.d.ts +4 -0
- package/dist/api/queue/getAssignments.d.ts.map +1 -0
- package/dist/api/queue/getAssignments.js +19 -0
- package/dist/api/queue/getAssignments.js.map +1 -0
- package/dist/api/queue/listQueues.d.ts +4 -0
- package/dist/api/queue/listQueues.d.ts.map +1 -0
- package/dist/api/queue/listQueues.js +29 -0
- package/dist/api/queue/listQueues.js.map +1 -0
- package/dist/api/queue/routeReports.d.ts +4 -0
- package/dist/api/queue/routeReports.d.ts.map +1 -0
- package/dist/api/queue/routeReports.js +33 -0
- package/dist/api/queue/routeReports.js.map +1 -0
- package/dist/api/queue/unassignModerator.d.ts +4 -0
- package/dist/api/queue/unassignModerator.d.ts.map +1 -0
- package/dist/api/queue/unassignModerator.js +24 -0
- package/dist/api/queue/unassignModerator.js.map +1 -0
- package/dist/api/queue/updateQueue.d.ts +4 -0
- package/dist/api/queue/updateQueue.d.ts.map +1 -0
- package/dist/api/queue/updateQueue.js +39 -0
- package/dist/api/queue/updateQueue.js.map +1 -0
- package/dist/api/report/assignModerator.d.ts +4 -0
- package/dist/api/report/assignModerator.d.ts.map +1 -0
- package/dist/api/report/assignModerator.js +33 -0
- package/dist/api/report/assignModerator.js.map +1 -0
- package/dist/api/report/createActivity.d.ts +4 -0
- package/dist/api/report/createActivity.d.ts.map +1 -0
- package/dist/api/report/createActivity.js +44 -0
- package/dist/api/report/createActivity.js.map +1 -0
- package/dist/api/report/getAssignments.d.ts +4 -0
- package/dist/api/report/getAssignments.d.ts.map +1 -0
- package/dist/api/report/getAssignments.js +19 -0
- package/dist/api/report/getAssignments.js.map +1 -0
- package/dist/api/report/getHistoricalStats.d.ts +4 -0
- package/dist/api/report/getHistoricalStats.d.ts.map +1 -0
- package/dist/api/report/getHistoricalStats.js +32 -0
- package/dist/api/report/getHistoricalStats.js.map +1 -0
- package/dist/api/report/getLatestReport.d.ts +4 -0
- package/dist/api/report/getLatestReport.d.ts.map +1 -0
- package/dist/api/report/getLatestReport.js +31 -0
- package/dist/api/report/getLatestReport.js.map +1 -0
- package/dist/api/report/getLiveStats.d.ts +4 -0
- package/dist/api/report/getLiveStats.d.ts.map +1 -0
- package/dist/api/report/getLiveStats.js +25 -0
- package/dist/api/report/getLiveStats.js.map +1 -0
- package/dist/api/report/getReport.d.ts +4 -0
- package/dist/api/report/getReport.d.ts.map +1 -0
- package/dist/api/report/getReport.js +35 -0
- package/dist/api/report/getReport.js.map +1 -0
- package/dist/api/report/listActivities.d.ts +4 -0
- package/dist/api/report/listActivities.d.ts.map +1 -0
- package/dist/api/report/listActivities.js +25 -0
- package/dist/api/report/listActivities.js.map +1 -0
- package/dist/api/report/queryReports.d.ts +4 -0
- package/dist/api/report/queryReports.d.ts.map +1 -0
- package/dist/api/report/queryReports.js +29 -0
- package/dist/api/report/queryReports.js.map +1 -0
- package/dist/api/report/reassignQueue.d.ts +4 -0
- package/dist/api/report/reassignQueue.d.ts.map +1 -0
- package/dist/api/report/reassignQueue.js +45 -0
- package/dist/api/report/reassignQueue.js.map +1 -0
- package/dist/api/report/refreshStats.d.ts +4 -0
- package/dist/api/report/refreshStats.d.ts.map +1 -0
- package/dist/api/report/refreshStats.js +26 -0
- package/dist/api/report/refreshStats.js.map +1 -0
- package/dist/api/report/unassignModerator.d.ts +4 -0
- package/dist/api/report/unassignModerator.d.ts.map +1 -0
- package/dist/api/report/unassignModerator.js +21 -0
- package/dist/api/report/unassignModerator.js.map +1 -0
- package/dist/api/util.d.ts +2 -0
- package/dist/api/util.d.ts.map +1 -1
- package/dist/api/util.js +9 -1
- package/dist/api/util.js.map +1 -1
- package/dist/assignment/index.d.ts +89 -0
- package/dist/assignment/index.d.ts.map +1 -0
- package/dist/assignment/index.js +537 -0
- package/dist/assignment/index.js.map +1 -0
- package/dist/config/config.d.ts +14 -0
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +9 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/env.d.ts +3 -0
- package/dist/config/env.d.ts.map +1 -1
- package/dist/config/env.js +3 -0
- package/dist/config/env.js.map +1 -1
- package/dist/context.d.ts +9 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +31 -10
- package/dist/context.js.map +1 -1
- package/dist/daemon/context.d.ts +6 -0
- package/dist/daemon/context.d.ts.map +1 -1
- package/dist/daemon/context.js +28 -4
- package/dist/daemon/context.js.map +1 -1
- package/dist/daemon/job-cursor.d.ts +5 -0
- package/dist/daemon/job-cursor.d.ts.map +1 -0
- package/dist/daemon/job-cursor.js +28 -0
- package/dist/daemon/job-cursor.js.map +1 -0
- package/dist/daemon/queue-router.d.ts +17 -0
- package/dist/daemon/queue-router.d.ts.map +1 -0
- package/dist/daemon/queue-router.js +114 -0
- package/dist/daemon/queue-router.js.map +1 -0
- package/dist/daemon/stats-computer.d.ts +51 -0
- package/dist/daemon/stats-computer.d.ts.map +1 -0
- package/dist/daemon/stats-computer.js +117 -0
- package/dist/daemon/stats-computer.js.map +1 -0
- package/dist/daemon/strike-expiry-processor.d.ts.map +1 -1
- package/dist/daemon/strike-expiry-processor.js +4 -19
- package/dist/daemon/strike-expiry-processor.js.map +1 -1
- package/dist/db/migrations/20260219T164523000Z-create-report-table.d.ts +4 -0
- package/dist/db/migrations/20260219T164523000Z-create-report-table.d.ts.map +1 -0
- package/dist/db/migrations/20260219T164523000Z-create-report-table.js +126 -0
- package/dist/db/migrations/20260219T164523000Z-create-report-table.js.map +1 -0
- package/dist/db/migrations/20260219T165302248Z-moderator-assignment.d.ts +4 -0
- package/dist/db/migrations/20260219T165302248Z-moderator-assignment.d.ts.map +1 -0
- package/dist/db/migrations/20260219T165302248Z-moderator-assignment.js +35 -0
- package/dist/db/migrations/20260219T165302248Z-moderator-assignment.js.map +1 -0
- package/dist/db/migrations/20260225T000000000Z-add-report-queue-table.d.ts +4 -0
- package/dist/db/migrations/20260225T000000000Z-add-report-queue-table.d.ts.map +1 -0
- package/dist/db/migrations/20260225T000000000Z-add-report-queue-table.js +36 -0
- package/dist/db/migrations/20260225T000000000Z-add-report-queue-table.js.map +1 -0
- package/dist/db/migrations/20260313T000000000Z-add-report-activity-table.d.ts +4 -0
- package/dist/db/migrations/20260313T000000000Z-add-report-activity-table.d.ts.map +1 -0
- package/dist/db/migrations/20260313T000000000Z-add-report-activity-table.js +39 -0
- package/dist/db/migrations/20260313T000000000Z-add-report-activity-table.js.map +1 -0
- package/dist/db/migrations/20260318T152058935Z-add-report-stat.d.ts +4 -0
- package/dist/db/migrations/20260318T152058935Z-add-report-stat.d.ts.map +1 -0
- package/dist/db/migrations/20260318T152058935Z-add-report-stat.js +34 -0
- package/dist/db/migrations/20260318T152058935Z-add-report-stat.js.map +1 -0
- package/dist/db/migrations/index.d.ts +5 -0
- package/dist/db/migrations/index.d.ts.map +1 -1
- package/dist/db/migrations/index.js +6 -1
- package/dist/db/migrations/index.js.map +1 -1
- package/dist/db/pagination.d.ts +31 -0
- package/dist/db/pagination.d.ts.map +1 -1
- package/dist/db/pagination.js +74 -1
- package/dist/db/pagination.js.map +1 -1
- package/dist/db/schema/index.d.ts +6 -1
- package/dist/db/schema/index.d.ts.map +1 -1
- package/dist/db/schema/index.js.map +1 -1
- package/dist/db/schema/moderator_assignment.d.ts +14 -0
- package/dist/db/schema/moderator_assignment.d.ts.map +1 -0
- package/dist/db/schema/moderator_assignment.js +5 -0
- package/dist/db/schema/moderator_assignment.js.map +1 -0
- package/dist/db/schema/report.d.ts +25 -0
- package/dist/db/schema/report.d.ts.map +1 -0
- package/dist/db/schema/report.js +5 -0
- package/dist/db/schema/report.js.map +1 -0
- package/dist/db/schema/report_activity.d.ts +18 -0
- package/dist/db/schema/report_activity.d.ts.map +1 -0
- package/dist/db/schema/report_activity.js +5 -0
- package/dist/db/schema/report_activity.js.map +1 -0
- package/dist/db/schema/report_queue.d.ts +19 -0
- package/dist/db/schema/report_queue.d.ts.map +1 -0
- package/dist/db/schema/report_queue.js +5 -0
- package/dist/db/schema/report_queue.js.map +1 -0
- package/dist/db/schema/report_stat.d.ts +20 -0
- package/dist/db/schema/report_stat.d.ts.map +1 -0
- package/dist/db/schema/report_stat.js +5 -0
- package/dist/db/schema/report_stat.js.map +1 -0
- package/dist/lexicon/index.d.ts +50 -0
- package/dist/lexicon/index.d.ts.map +1 -1
- package/dist/lexicon/index.js +120 -2
- package/dist/lexicon/index.js.map +1 -1
- package/dist/lexicon/lexicons.d.ts +10535 -7389
- package/dist/lexicon/lexicons.d.ts.map +1 -1
- package/dist/lexicon/lexicons.js +1789 -122
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/lexicon/types/app/bsky/embed/external.d.ts +2 -0
- package/dist/lexicon/types/app/bsky/embed/external.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/embed/external.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/emitEvent.d.ts +19 -0
- package/dist/lexicon/types/tools/ozone/moderation/emitEvent.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/emitEvent.js +9 -0
- package/dist/lexicon/types/tools/ozone/moderation/emitEvent.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/queue/assignModerator.d.ts +27 -0
- package/dist/lexicon/types/tools/ozone/queue/assignModerator.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/assignModerator.js +7 -0
- package/dist/lexicon/types/tools/ozone/queue/assignModerator.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/createQueue.d.ts +35 -0
- package/dist/lexicon/types/tools/ozone/queue/createQueue.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/createQueue.js +7 -0
- package/dist/lexicon/types/tools/ozone/queue/createQueue.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/defs.d.ts +62 -0
- package/dist/lexicon/types/tools/ozone/queue/defs.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/defs.js +34 -0
- package/dist/lexicon/types/tools/ozone/queue/defs.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/deleteQueue.d.ts +29 -0
- package/dist/lexicon/types/tools/ozone/queue/deleteQueue.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/deleteQueue.js +7 -0
- package/dist/lexicon/types/tools/ozone/queue/deleteQueue.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/getAssignments.d.ts +30 -0
- package/dist/lexicon/types/tools/ozone/queue/getAssignments.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/getAssignments.js +7 -0
- package/dist/lexicon/types/tools/ozone/queue/getAssignments.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/listQueues.d.ts +32 -0
- package/dist/lexicon/types/tools/ozone/queue/listQueues.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/listQueues.js +7 -0
- package/dist/lexicon/types/tools/ozone/queue/listQueues.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/routeReports.d.ts +31 -0
- package/dist/lexicon/types/tools/ozone/queue/routeReports.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/routeReports.js +7 -0
- package/dist/lexicon/types/tools/ozone/queue/routeReports.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/unassignModerator.d.ts +18 -0
- package/dist/lexicon/types/tools/ozone/queue/unassignModerator.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/unassignModerator.js +7 -0
- package/dist/lexicon/types/tools/ozone/queue/unassignModerator.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/updateQueue.d.ts +32 -0
- package/dist/lexicon/types/tools/ozone/queue/updateQueue.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/queue/updateQueue.js +7 -0
- package/dist/lexicon/types/tools/ozone/queue/updateQueue.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/assignModerator.d.ts +31 -0
- package/dist/lexicon/types/tools/ozone/report/assignModerator.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/assignModerator.js +7 -0
- package/dist/lexicon/types/tools/ozone/report/assignModerator.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/createActivity.d.ts +37 -0
- package/dist/lexicon/types/tools/ozone/report/createActivity.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/createActivity.js +7 -0
- package/dist/lexicon/types/tools/ozone/report/createActivity.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/defs.d.ts +185 -0
- package/dist/lexicon/types/tools/ozone/report/defs.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/report/defs.js +108 -0
- package/dist/lexicon/types/tools/ozone/report/defs.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/report/getAssignments.d.ts +30 -0
- package/dist/lexicon/types/tools/ozone/report/getAssignments.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/getAssignments.js +7 -0
- package/dist/lexicon/types/tools/ozone/report/getAssignments.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/getHistoricalStats.d.ts +36 -0
- package/dist/lexicon/types/tools/ozone/report/getHistoricalStats.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/getHistoricalStats.js +7 -0
- package/dist/lexicon/types/tools/ozone/report/getHistoricalStats.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/getLatestReport.d.ts +21 -0
- package/dist/lexicon/types/tools/ozone/report/getLatestReport.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/getLatestReport.js +7 -0
- package/dist/lexicon/types/tools/ozone/report/getLatestReport.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/getLiveStats.d.ts +27 -0
- package/dist/lexicon/types/tools/ozone/report/getLiveStats.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/getLiveStats.js +7 -0
- package/dist/lexicon/types/tools/ozone/report/getLiveStats.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/getReport.d.ts +22 -0
- package/dist/lexicon/types/tools/ozone/report/getReport.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/getReport.js +7 -0
- package/dist/lexicon/types/tools/ozone/report/getReport.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/listActivities.d.ts +26 -0
- package/dist/lexicon/types/tools/ozone/report/listActivities.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/listActivities.js +7 -0
- package/dist/lexicon/types/tools/ozone/report/listActivities.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/queryReports.d.ts +48 -0
- package/dist/lexicon/types/tools/ozone/report/queryReports.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/queryReports.js +7 -0
- package/dist/lexicon/types/tools/ozone/report/queryReports.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/reassignQueue.d.ts +31 -0
- package/dist/lexicon/types/tools/ozone/report/reassignQueue.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/reassignQueue.js +7 -0
- package/dist/lexicon/types/tools/ozone/report/reassignQueue.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/refreshStats.d.ts +28 -0
- package/dist/lexicon/types/tools/ozone/report/refreshStats.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/refreshStats.js +7 -0
- package/dist/lexicon/types/tools/ozone/report/refreshStats.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/unassignModerator.d.ts +25 -0
- package/dist/lexicon/types/tools/ozone/report/unassignModerator.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/unassignModerator.js +7 -0
- package/dist/lexicon/types/tools/ozone/report/unassignModerator.js.map +1 -0
- package/dist/mod-service/index.d.ts +3 -1
- package/dist/mod-service/index.d.ts.map +1 -1
- package/dist/mod-service/index.js +39 -2
- package/dist/mod-service/index.js.map +1 -1
- package/dist/mod-service/report.d.ts +64 -0
- package/dist/mod-service/report.d.ts.map +1 -0
- package/dist/mod-service/report.js +282 -0
- package/dist/mod-service/report.js.map +1 -0
- package/dist/mod-service/status.d.ts +20 -0
- package/dist/mod-service/status.d.ts.map +1 -1
- package/dist/queue/service.d.ts +86 -0
- package/dist/queue/service.d.ts.map +1 -0
- package/dist/queue/service.js +430 -0
- package/dist/queue/service.js.map +1 -0
- package/dist/report/activity.d.ts +77 -0
- package/dist/report/activity.d.ts.map +1 -0
- package/dist/report/activity.js +141 -0
- package/dist/report/activity.js.map +1 -0
- package/dist/report/handle-report-update.d.ts +47 -0
- package/dist/report/handle-report-update.d.ts.map +1 -0
- package/dist/report/handle-report-update.js +178 -0
- package/dist/report/handle-report-update.js.map +1 -0
- package/dist/report/reassign.d.ts +10 -0
- package/dist/report/reassign.d.ts.map +1 -0
- package/dist/report/reassign.js +75 -0
- package/dist/report/reassign.js.map +1 -0
- package/dist/report/stats.d.ts +105 -0
- package/dist/report/stats.d.ts.map +1 -0
- package/dist/report/stats.js +619 -0
- package/dist/report/stats.js.map +1 -0
- package/dist/report/views.d.ts +111 -0
- package/dist/report/views.d.ts.map +1 -0
- package/dist/report/views.js +156 -0
- package/dist/report/views.js.map +1 -0
- package/dist/team/index.d.ts +1 -0
- package/dist/team/index.d.ts.map +1 -1
- package/dist/team/index.js +11 -0
- package/dist/team/index.js.map +1 -1
- package/package.json +3 -3
- package/src/api/index.ts +40 -0
- package/src/api/moderation/emitEvent.ts +38 -0
- package/src/api/queue/assignModerator.ts +31 -0
- package/src/api/queue/createQueue.ts +62 -0
- package/src/api/queue/deleteQueue.ts +56 -0
- package/src/api/queue/getAssignments.ts +19 -0
- package/src/api/queue/listQueues.ts +39 -0
- package/src/api/queue/routeReports.ts +44 -0
- package/src/api/queue/unassignModerator.ts +26 -0
- package/src/api/queue/updateQueue.ts +54 -0
- package/src/api/report/assignModerator.ts +36 -0
- package/src/api/report/createActivity.ts +57 -0
- package/src/api/report/getAssignments.ts +20 -0
- package/src/api/report/getHistoricalStats.ts +41 -0
- package/src/api/report/getLatestReport.ts +44 -0
- package/src/api/report/getLiveStats.ts +26 -0
- package/src/api/report/getReport.ts +55 -0
- package/src/api/report/listActivities.ts +34 -0
- package/src/api/report/queryReports.ts +44 -0
- package/src/api/report/reassignQueue.ts +68 -0
- package/src/api/report/refreshStats.ts +27 -0
- package/src/api/report/unassignModerator.ts +21 -0
- package/src/api/util.ts +12 -0
- package/src/assignment/index.ts +731 -0
- package/src/config/config.ts +27 -0
- package/src/config/env.ts +8 -0
- package/src/context.ts +31 -0
- package/src/daemon/context.ts +34 -0
- package/src/daemon/job-cursor.ts +33 -0
- package/src/daemon/queue-router.ts +101 -0
- package/src/daemon/stats-computer.ts +101 -0
- package/src/daemon/strike-expiry-processor.ts +4 -20
- package/src/db/migrations/20260219T164523000Z-create-report-table.ts +155 -0
- package/src/db/migrations/20260219T165302248Z-moderator-assignment.ts +42 -0
- package/src/db/migrations/20260225T000000000Z-add-report-queue-table.ts +41 -0
- package/src/db/migrations/20260313T000000000Z-add-report-activity-table.ts +48 -0
- package/src/db/migrations/20260318T152058935Z-add-report-stat.ts +35 -0
- package/src/db/migrations/index.ts +5 -0
- package/src/db/pagination.ts +85 -0
- package/src/db/schema/index.ts +10 -0
- package/src/db/schema/moderator_assignment.ts +16 -0
- package/src/db/schema/report.ts +27 -0
- package/src/db/schema/report_activity.ts +22 -0
- package/src/db/schema/report_queue.ts +21 -0
- package/src/db/schema/report_stat.ts +27 -0
- package/src/lexicon/index.ts +280 -0
- package/src/lexicon/lexicons.ts +1910 -160
- package/src/lexicon/types/app/bsky/embed/external.ts +2 -0
- package/src/lexicon/types/tools/ozone/moderation/emitEvent.ts +24 -0
- package/src/lexicon/types/tools/ozone/queue/assignModerator.ts +46 -0
- package/src/lexicon/types/tools/ozone/queue/createQueue.ts +54 -0
- package/src/lexicon/types/tools/ozone/queue/defs.ts +99 -0
- package/src/lexicon/types/tools/ozone/queue/deleteQueue.ts +48 -0
- package/src/lexicon/types/tools/ozone/queue/getAssignments.ts +48 -0
- package/src/lexicon/types/tools/ozone/queue/listQueues.ts +50 -0
- package/src/lexicon/types/tools/ozone/queue/routeReports.ts +50 -0
- package/src/lexicon/types/tools/ozone/queue/unassignModerator.ts +37 -0
- package/src/lexicon/types/tools/ozone/queue/updateQueue.ts +51 -0
- package/src/lexicon/types/tools/ozone/report/assignModerator.ts +50 -0
- package/src/lexicon/types/tools/ozone/report/createActivity.ts +60 -0
- package/src/lexicon/types/tools/ozone/report/defs.ts +327 -0
- package/src/lexicon/types/tools/ozone/report/getAssignments.ts +48 -0
- package/src/lexicon/types/tools/ozone/report/getHistoricalStats.ts +54 -0
- package/src/lexicon/types/tools/ozone/report/getLatestReport.ts +39 -0
- package/src/lexicon/types/tools/ozone/report/getLiveStats.ts +45 -0
- package/src/lexicon/types/tools/ozone/report/getReport.ts +38 -0
- package/src/lexicon/types/tools/ozone/report/listActivities.ts +44 -0
- package/src/lexicon/types/tools/ozone/report/queryReports.ts +72 -0
- package/src/lexicon/types/tools/ozone/report/reassignQueue.ts +55 -0
- package/src/lexicon/types/tools/ozone/report/refreshStats.ts +46 -0
- package/src/lexicon/types/tools/ozone/report/unassignModerator.ts +44 -0
- package/src/mod-service/index.ts +45 -3
- package/src/mod-service/report.ts +408 -0
- package/src/queue/service.ts +599 -0
- package/src/report/activity.ts +234 -0
- package/src/report/handle-report-update.ts +209 -0
- package/src/report/reassign.ts +109 -0
- package/src/report/stats.ts +850 -0
- package/src/report/views.ts +241 -0
- package/src/team/index.ts +11 -0
- package/tests/get-report.test.ts +136 -0
- package/tests/query-reports.test.ts +608 -0
- package/tests/queue-assignment.test.ts +428 -0
- package/tests/queue-router.test.ts +306 -0
- package/tests/queues.test.ts +690 -0
- package/tests/report-action.test.ts +308 -0
- package/tests/report-activity.test.ts +567 -0
- package/tests/report-assignment.test.ts +517 -0
- package/tests/report-reassign-queue.test.ts +340 -0
- package/tests/report-routing.test.ts +245 -0
- package/tests/report-stats.test.ts +545 -0
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
} from '../../lexicon/types/tools/ozone/moderation/defs'
|
|
27
27
|
import { HandlerInput } from '../../lexicon/types/tools/ozone/moderation/emitEvent'
|
|
28
28
|
import { httpLogger } from '../../logger'
|
|
29
|
+
import { processReportAction } from '../../mod-service/report'
|
|
29
30
|
import { subjectFromInput } from '../../mod-service/subject'
|
|
30
31
|
import { SettingService } from '../../setting/service'
|
|
31
32
|
import { TagService } from '../../tag-service'
|
|
@@ -240,6 +241,21 @@ const handleModerationEvent = async ({
|
|
|
240
241
|
}
|
|
241
242
|
}
|
|
242
243
|
|
|
244
|
+
// Validate reportAction if provided (actual processing happens after event is logged)
|
|
245
|
+
if (input.body.reportAction) {
|
|
246
|
+
// Validate that at least one targeting criteria is provided
|
|
247
|
+
const { reportAction } = input.body
|
|
248
|
+
if (
|
|
249
|
+
!reportAction.ids?.length &&
|
|
250
|
+
!reportAction.types?.length &&
|
|
251
|
+
!reportAction.all
|
|
252
|
+
) {
|
|
253
|
+
throw new InvalidRequestError(
|
|
254
|
+
'reportAction must specify ids, types, or all',
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
243
259
|
const result = await moderationTxn.logEvent({
|
|
244
260
|
event,
|
|
245
261
|
subject,
|
|
@@ -248,6 +264,28 @@ const handleModerationEvent = async ({
|
|
|
248
264
|
externalId,
|
|
249
265
|
})
|
|
250
266
|
|
|
267
|
+
// Update reports if reportAction was provided
|
|
268
|
+
if (input.body.reportAction) {
|
|
269
|
+
const subjectUri = subject.isRecord() ? subject.uri : null
|
|
270
|
+
try {
|
|
271
|
+
await processReportAction({
|
|
272
|
+
db: dbTxn,
|
|
273
|
+
reportAction: input.body.reportAction,
|
|
274
|
+
subjectDid: subject.did,
|
|
275
|
+
subjectUri,
|
|
276
|
+
eventId: result.event.id,
|
|
277
|
+
eventType: event.$type,
|
|
278
|
+
createdBy,
|
|
279
|
+
})
|
|
280
|
+
} catch (err) {
|
|
281
|
+
throw new InvalidRequestError(
|
|
282
|
+
err instanceof Error
|
|
283
|
+
? err.message
|
|
284
|
+
: 'Failed to process report action',
|
|
285
|
+
)
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
251
289
|
const tagService = new TagService(
|
|
252
290
|
subject,
|
|
253
291
|
result.subjectStatus,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ForbiddenError } from '@atproto/xrpc-server'
|
|
2
|
+
import { AppContext } from '../../context'
|
|
3
|
+
import { Server } from '../../lexicon'
|
|
4
|
+
import { getAuthDid } from '../util'
|
|
5
|
+
|
|
6
|
+
export default function (server: Server, ctx: AppContext) {
|
|
7
|
+
server.tools.ozone.queue.assignModerator({
|
|
8
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
9
|
+
handler: async ({ input, auth }) => {
|
|
10
|
+
const { queueId, did } = input.body
|
|
11
|
+
const authDid = getAuthDid(auth, ctx.cfg.service.did)
|
|
12
|
+
|
|
13
|
+
// RBAC
|
|
14
|
+
if (!auth.credentials.isModerator) {
|
|
15
|
+
throw new ForbiddenError('Unauthorized')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// RuBAC
|
|
19
|
+
if (did !== authDid && !auth.credentials.isAdmin) {
|
|
20
|
+
throw new ForbiddenError('Unauthorized')
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const result = await ctx.assignmentService.assignQueue({ did, queueId })
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
encoding: 'application/json',
|
|
27
|
+
body: result,
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { AuthRequiredError, InvalidRequestError } from '@atproto/xrpc-server'
|
|
2
|
+
import { AppContext } from '../../context'
|
|
3
|
+
import { Server } from '../../lexicon'
|
|
4
|
+
|
|
5
|
+
const VALID_SUBJECT_TYPES = ['account', 'record', 'message']
|
|
6
|
+
|
|
7
|
+
export default function (server: Server, ctx: AppContext) {
|
|
8
|
+
server.tools.ozone.queue.createQueue({
|
|
9
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
10
|
+
handler: async ({ input, auth }) => {
|
|
11
|
+
const access = auth.credentials
|
|
12
|
+
|
|
13
|
+
if (!access.isModerator) {
|
|
14
|
+
throw new AuthRequiredError('Must be a moderator to create a queue')
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const { name, subjectTypes, collection, reportTypes, description } =
|
|
18
|
+
input.body
|
|
19
|
+
const createdBy =
|
|
20
|
+
access.type === 'admin_token' ? 'admin_token' : access.iss
|
|
21
|
+
|
|
22
|
+
const invalidTypes = subjectTypes.filter(
|
|
23
|
+
(t) => !VALID_SUBJECT_TYPES.includes(t),
|
|
24
|
+
)
|
|
25
|
+
if (invalidTypes.length > 0) {
|
|
26
|
+
throw new InvalidRequestError(
|
|
27
|
+
`Invalid subject types: ${invalidTypes.join(', ')}. Allowed values: ${VALID_SUBJECT_TYPES.join(', ')}`,
|
|
28
|
+
'InvalidSubjectType',
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (collection && !subjectTypes.includes('record')) {
|
|
33
|
+
throw new InvalidRequestError(
|
|
34
|
+
'collection can only be specified when subjectTypes includes "record"',
|
|
35
|
+
'InvalidCollection',
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const queueService = ctx.queueService(ctx.db)
|
|
40
|
+
|
|
41
|
+
await queueService.checkConflict({
|
|
42
|
+
subjectTypes,
|
|
43
|
+
collection,
|
|
44
|
+
reportTypes,
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const queue = await queueService.create({
|
|
48
|
+
name,
|
|
49
|
+
subjectTypes,
|
|
50
|
+
collection,
|
|
51
|
+
reportTypes,
|
|
52
|
+
description,
|
|
53
|
+
createdBy,
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
encoding: 'application/json',
|
|
58
|
+
body: { queue: queueService.view(queue) },
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { AuthRequiredError, InvalidRequestError } from '@atproto/xrpc-server'
|
|
2
|
+
import { AppContext } from '../../context'
|
|
3
|
+
import { Server } from '../../lexicon'
|
|
4
|
+
|
|
5
|
+
export default function (server: Server, ctx: AppContext) {
|
|
6
|
+
server.tools.ozone.queue.deleteQueue({
|
|
7
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
8
|
+
handler: async ({ input, auth }) => {
|
|
9
|
+
const access = auth.credentials
|
|
10
|
+
|
|
11
|
+
if (!access.isModerator) {
|
|
12
|
+
throw new AuthRequiredError('Must be a moderator to delete a queue')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { queueId, migrateToQueueId } = input.body
|
|
16
|
+
|
|
17
|
+
const queueService = ctx.queueService(ctx.db)
|
|
18
|
+
|
|
19
|
+
const existing = await queueService.getById(queueId)
|
|
20
|
+
if (!existing) {
|
|
21
|
+
throw new InvalidRequestError(
|
|
22
|
+
`Queue with id ${queueId} does not exist`,
|
|
23
|
+
'QueueNotFound',
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (migrateToQueueId !== undefined) {
|
|
28
|
+
const targetQueue = await queueService.getById(migrateToQueueId)
|
|
29
|
+
if (!targetQueue) {
|
|
30
|
+
throw new InvalidRequestError(
|
|
31
|
+
`Target queue with id ${migrateToQueueId} does not exist`,
|
|
32
|
+
'QueueNotFound',
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Migrate non-closed reports before soft-deleting the queue.
|
|
38
|
+
// Closed reports are left assigned to the deleted queue — their history is preserved.
|
|
39
|
+
// Non-closed reports go to migrateToQueueId if specified, otherwise to -1 (unmatched).
|
|
40
|
+
const reportsMigrated = await queueService.migrateReports(
|
|
41
|
+
queueId,
|
|
42
|
+
migrateToQueueId,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
await queueService.delete(queueId)
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
encoding: 'application/json',
|
|
49
|
+
body: {
|
|
50
|
+
deleted: true,
|
|
51
|
+
reportsMigrated,
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AppContext } from '../../context'
|
|
2
|
+
import { Server } from '../../lexicon'
|
|
3
|
+
|
|
4
|
+
export default function (server: Server, ctx: AppContext) {
|
|
5
|
+
server.tools.ozone.queue.getAssignments({
|
|
6
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
7
|
+
handler: async ({ params }) => {
|
|
8
|
+
const result = await ctx.assignmentService.getQueueAssignments(params)
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
encoding: 'application/json',
|
|
12
|
+
body: {
|
|
13
|
+
assignments: result.assignments,
|
|
14
|
+
cursor: result.cursor,
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { AppContext } from '../../context'
|
|
2
|
+
import { Server } from '../../lexicon'
|
|
3
|
+
|
|
4
|
+
export default function (server: Server, ctx: AppContext) {
|
|
5
|
+
server.tools.ozone.queue.listQueues({
|
|
6
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
7
|
+
handler: async ({ params }) => {
|
|
8
|
+
const {
|
|
9
|
+
limit = 50,
|
|
10
|
+
cursor,
|
|
11
|
+
enabled,
|
|
12
|
+
subjectType,
|
|
13
|
+
collection,
|
|
14
|
+
reportTypes,
|
|
15
|
+
} = params
|
|
16
|
+
|
|
17
|
+
const queueService = ctx.queueService(ctx.db)
|
|
18
|
+
|
|
19
|
+
const result = await queueService.list({
|
|
20
|
+
limit,
|
|
21
|
+
cursor,
|
|
22
|
+
enabled,
|
|
23
|
+
subjectType,
|
|
24
|
+
collection,
|
|
25
|
+
reportTypes,
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const queues = await queueService.viewsWithStats(result.queues)
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
encoding: 'application/json',
|
|
32
|
+
body: {
|
|
33
|
+
queues,
|
|
34
|
+
cursor: result.cursor,
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AuthRequiredError, InvalidRequestError } from '@atproto/xrpc-server'
|
|
2
|
+
import { AppContext } from '../../context'
|
|
3
|
+
import { Server } from '../../lexicon'
|
|
4
|
+
|
|
5
|
+
const MAX_REPORTS = 5000
|
|
6
|
+
|
|
7
|
+
export default function (server: Server, ctx: AppContext) {
|
|
8
|
+
server.tools.ozone.queue.routeReports({
|
|
9
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
10
|
+
handler: async ({ input, auth }) => {
|
|
11
|
+
const access = auth.credentials
|
|
12
|
+
const { startReportId, endReportId } = input.body
|
|
13
|
+
|
|
14
|
+
if (!access.isModerator) {
|
|
15
|
+
throw new AuthRequiredError('Must be an admin to re-route reports')
|
|
16
|
+
}
|
|
17
|
+
if (startReportId > endReportId) {
|
|
18
|
+
throw new InvalidRequestError(
|
|
19
|
+
'startReportId must be less than or equal to endReportId',
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
if (endReportId - startReportId + 1 > MAX_REPORTS) {
|
|
23
|
+
throw new InvalidRequestError(
|
|
24
|
+
`Cannot route more than ${MAX_REPORTS} reports at a time`,
|
|
25
|
+
'OutOfRange',
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const queueService = ctx.queueService(ctx.db)
|
|
30
|
+
const { assigned, unmatched } = await queueService.assignReportBatch(
|
|
31
|
+
{ start: startReportId, end: endReportId, limit: MAX_REPORTS },
|
|
32
|
+
{ includeUnmatched: true },
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
encoding: 'application/json',
|
|
37
|
+
body: {
|
|
38
|
+
assigned,
|
|
39
|
+
unmatched,
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ForbiddenError } from '@atproto/xrpc-server'
|
|
2
|
+
import { AppContext } from '../../context'
|
|
3
|
+
import { Server } from '../../lexicon'
|
|
4
|
+
import { getAuthDid } from '../util'
|
|
5
|
+
|
|
6
|
+
export default function (server: Server, ctx: AppContext) {
|
|
7
|
+
server.tools.ozone.queue.unassignModerator({
|
|
8
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
9
|
+
handler: async ({ input, auth }) => {
|
|
10
|
+
const { queueId, did } = input.body
|
|
11
|
+
const authDid = getAuthDid(auth, ctx.cfg.service.did)
|
|
12
|
+
|
|
13
|
+
// RBAC
|
|
14
|
+
if (!auth.credentials.isModerator) {
|
|
15
|
+
throw new ForbiddenError('Unauthorized')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// RuBAC
|
|
19
|
+
if (did !== authDid && !auth.credentials.isAdmin) {
|
|
20
|
+
throw new ForbiddenError('Unauthorized')
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
await ctx.assignmentService.unassignQueue({ did, queueId })
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AuthRequiredError, InvalidRequestError } from '@atproto/xrpc-server'
|
|
2
|
+
import { AppContext } from '../../context'
|
|
3
|
+
import { Server } from '../../lexicon'
|
|
4
|
+
|
|
5
|
+
export default function (server: Server, ctx: AppContext) {
|
|
6
|
+
server.tools.ozone.queue.updateQueue({
|
|
7
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
8
|
+
handler: async ({ input, auth }) => {
|
|
9
|
+
const access = auth.credentials
|
|
10
|
+
|
|
11
|
+
if (!access.isModerator) {
|
|
12
|
+
throw new AuthRequiredError('Must be a moderator to update a queue')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { queueId, name, enabled, description } = input.body
|
|
16
|
+
|
|
17
|
+
if (
|
|
18
|
+
name === undefined &&
|
|
19
|
+
enabled === undefined &&
|
|
20
|
+
description === undefined
|
|
21
|
+
) {
|
|
22
|
+
throw new InvalidRequestError(
|
|
23
|
+
'At least one of name, enabled, or description must be provided',
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const queueService = ctx.queueService(ctx.db)
|
|
28
|
+
|
|
29
|
+
const existing = await queueService.getById(queueId)
|
|
30
|
+
if (!existing) {
|
|
31
|
+
throw new InvalidRequestError(
|
|
32
|
+
`Queue with id ${queueId} does not exist`,
|
|
33
|
+
'QueueNotFound',
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const updates: {
|
|
38
|
+
name?: string
|
|
39
|
+
enabled?: boolean
|
|
40
|
+
description?: string
|
|
41
|
+
} = {}
|
|
42
|
+
if (name !== undefined) updates.name = name
|
|
43
|
+
if (enabled !== undefined) updates.enabled = enabled
|
|
44
|
+
if (description !== undefined) updates.description = description
|
|
45
|
+
|
|
46
|
+
const queue = await queueService.update(queueId, updates)
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
encoding: 'application/json',
|
|
50
|
+
body: { queue: queueService.view(queue) },
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ForbiddenError } from '@atproto/xrpc-server'
|
|
2
|
+
import { AppContext } from '../../context'
|
|
3
|
+
import { Server } from '../../lexicon'
|
|
4
|
+
import { getAuthDid } from '../util'
|
|
5
|
+
|
|
6
|
+
export default function (server: Server, ctx: AppContext) {
|
|
7
|
+
server.tools.ozone.report.assignModerator({
|
|
8
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
9
|
+
handler: async ({ input, auth }) => {
|
|
10
|
+
const authDid = getAuthDid(auth, ctx.cfg.service.did)
|
|
11
|
+
const did = input.body.did ?? authDid
|
|
12
|
+
|
|
13
|
+
if (!did) {
|
|
14
|
+
throw new ForbiddenError('No one to assign report to')
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// RuBAC: only admins can assign to a different user
|
|
18
|
+
if (did !== authDid && !auth.credentials.isAdmin) {
|
|
19
|
+
throw new ForbiddenError('Unauthorized')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const result = await ctx.assignmentService.assignReport({
|
|
23
|
+
did,
|
|
24
|
+
createdBy: authDid,
|
|
25
|
+
reportId: input.body.reportId,
|
|
26
|
+
queueId: input.body.queueId,
|
|
27
|
+
isPermanent: input.body.isPermanent,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
encoding: 'application/json',
|
|
32
|
+
body: result,
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { InvalidRequestError } from '@atproto/xrpc-server'
|
|
2
|
+
import { AppContext } from '../../context'
|
|
3
|
+
import { Server } from '../../lexicon'
|
|
4
|
+
import {
|
|
5
|
+
ActivityType,
|
|
6
|
+
createReportActivity,
|
|
7
|
+
formatActivityView,
|
|
8
|
+
} from '../../report/activity'
|
|
9
|
+
import { getAuthDid } from '../util'
|
|
10
|
+
|
|
11
|
+
const VALID_ACTIVITY_TYPES = new Set<ActivityType>([
|
|
12
|
+
'queueActivity',
|
|
13
|
+
'assignmentActivity',
|
|
14
|
+
'escalationActivity',
|
|
15
|
+
'closeActivity',
|
|
16
|
+
'reopenActivity',
|
|
17
|
+
'noteActivity',
|
|
18
|
+
])
|
|
19
|
+
|
|
20
|
+
const DEFS_PREFIX = 'tools.ozone.report.defs#'
|
|
21
|
+
|
|
22
|
+
export default function (server: Server, ctx: AppContext) {
|
|
23
|
+
server.tools.ozone.report.createActivity({
|
|
24
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
25
|
+
handler: async ({ input, auth }) => {
|
|
26
|
+
const createdBy = getAuthDid(auth, ctx.cfg.service.did)
|
|
27
|
+
const { reportId, activity, internalNote, publicNote, isAutomated } =
|
|
28
|
+
input.body
|
|
29
|
+
|
|
30
|
+
const rawType = activity.$type ?? ''
|
|
31
|
+
const activityType = rawType.startsWith(DEFS_PREFIX)
|
|
32
|
+
? rawType.slice(DEFS_PREFIX.length)
|
|
33
|
+
: rawType
|
|
34
|
+
|
|
35
|
+
if (!VALID_ACTIVITY_TYPES.has(activityType as ActivityType)) {
|
|
36
|
+
throw new InvalidRequestError(
|
|
37
|
+
`Unknown activity type: ${rawType}`,
|
|
38
|
+
'InvalidActivityType',
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const row = await createReportActivity(ctx.db, {
|
|
43
|
+
reportId,
|
|
44
|
+
activityType: activityType as ActivityType,
|
|
45
|
+
internalNote: internalNote ?? undefined,
|
|
46
|
+
publicNote: publicNote ?? undefined,
|
|
47
|
+
isAutomated: isAutomated ?? false,
|
|
48
|
+
createdBy: createdBy ?? ctx.cfg.service.did,
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
encoding: 'application/json',
|
|
53
|
+
body: { activity: formatActivityView(row) },
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AppContext } from '../../context'
|
|
2
|
+
import { Server } from '../../lexicon'
|
|
3
|
+
|
|
4
|
+
export default function (server: Server, ctx: AppContext) {
|
|
5
|
+
server.tools.ozone.report.getAssignments({
|
|
6
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
7
|
+
handler: async ({ params }) => {
|
|
8
|
+
const { assignments, cursor } =
|
|
9
|
+
await ctx.assignmentService.getReportAssignments(params)
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
encoding: 'application/json',
|
|
13
|
+
body: {
|
|
14
|
+
assignments,
|
|
15
|
+
cursor,
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AppContext } from '../../context'
|
|
2
|
+
import { Server } from '../../lexicon'
|
|
3
|
+
import { viewHistoricalStats } from '../../report/views'
|
|
4
|
+
|
|
5
|
+
export default function (server: Server, ctx: AppContext) {
|
|
6
|
+
server.tools.ozone.report.getHistoricalStats({
|
|
7
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
8
|
+
handler: async ({ params }) => {
|
|
9
|
+
const {
|
|
10
|
+
queueId,
|
|
11
|
+
moderatorDid,
|
|
12
|
+
reportTypes,
|
|
13
|
+
startDate,
|
|
14
|
+
endDate,
|
|
15
|
+
limit,
|
|
16
|
+
cursor,
|
|
17
|
+
} = params
|
|
18
|
+
|
|
19
|
+
const reportStatsService = ctx.reportStatsService(ctx.db)
|
|
20
|
+
const result = await reportStatsService.getHistoricalStats({
|
|
21
|
+
group: {
|
|
22
|
+
queueId: queueId ?? null,
|
|
23
|
+
moderatorDid: moderatorDid ?? null,
|
|
24
|
+
reportTypes: reportTypes?.length ? reportTypes : null,
|
|
25
|
+
},
|
|
26
|
+
startDate,
|
|
27
|
+
endDate,
|
|
28
|
+
limit: limit ?? 30,
|
|
29
|
+
cursor,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
encoding: 'application/json',
|
|
34
|
+
body: {
|
|
35
|
+
stats: result.stats.map(viewHistoricalStats),
|
|
36
|
+
cursor: result.cursor,
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
})
|
|
41
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { InvalidRequestError } from '@atproto/xrpc-server'
|
|
2
|
+
import { AppContext } from '../../context'
|
|
3
|
+
import { Server } from '../../lexicon'
|
|
4
|
+
import { getLatestReport } from '../../mod-service/report'
|
|
5
|
+
import { buildReportView, hydrateReportInfo } from '../../report/views'
|
|
6
|
+
import { getPdsAccountInfos } from '../util'
|
|
7
|
+
|
|
8
|
+
export default function (server: Server, ctx: AppContext) {
|
|
9
|
+
server.tools.ozone.report.getLatestReport({
|
|
10
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
11
|
+
handler: async ({ auth, req }) => {
|
|
12
|
+
const db = ctx.db
|
|
13
|
+
const modService = ctx.modService(db)
|
|
14
|
+
const labelers = ctx.reqLabelers(req)
|
|
15
|
+
|
|
16
|
+
const report = await getLatestReport(db)
|
|
17
|
+
if (!report) {
|
|
18
|
+
throw new InvalidRequestError('No report found', 'NotFound')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const queueService = ctx.queueService(db)
|
|
22
|
+
const teamService = ctx.teamService(db)
|
|
23
|
+
const hydrated = await hydrateReportInfo(
|
|
24
|
+
[report],
|
|
25
|
+
modService.views,
|
|
26
|
+
(dids) => getPdsAccountInfos(ctx, dids),
|
|
27
|
+
(queueIds) => queueService.getViewsByIds(queueIds),
|
|
28
|
+
(dids) => teamService.viewByDids(dids),
|
|
29
|
+
labelers,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
encoding: 'application/json',
|
|
34
|
+
body: {
|
|
35
|
+
report: buildReportView(
|
|
36
|
+
report,
|
|
37
|
+
hydrated,
|
|
38
|
+
auth.credentials.isModerator,
|
|
39
|
+
),
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AppContext } from '../../context'
|
|
2
|
+
import { Server } from '../../lexicon'
|
|
3
|
+
import { viewLiveStats } from '../../report/views'
|
|
4
|
+
|
|
5
|
+
export default function (server: Server, ctx: AppContext) {
|
|
6
|
+
server.tools.ozone.report.getLiveStats({
|
|
7
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
8
|
+
handler: async ({ params }) => {
|
|
9
|
+
const { queueId, moderatorDid, reportTypes } = params
|
|
10
|
+
|
|
11
|
+
const reportStatsService = ctx.reportStatsService(ctx.db)
|
|
12
|
+
const row = await reportStatsService.getLiveStats({
|
|
13
|
+
queueId: queueId ?? null,
|
|
14
|
+
moderatorDid: moderatorDid ?? null,
|
|
15
|
+
reportTypes: reportTypes?.length ? reportTypes : null,
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
encoding: 'application/json',
|
|
20
|
+
body: {
|
|
21
|
+
stats: viewLiveStats(row),
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { InvalidRequestError } from '@atproto/xrpc-server'
|
|
2
|
+
import { AppContext } from '../../context'
|
|
3
|
+
import { Server } from '../../lexicon'
|
|
4
|
+
import { getReportById } from '../../mod-service/report'
|
|
5
|
+
import { buildReportView, hydrateReportInfo } from '../../report/views'
|
|
6
|
+
import { getPdsAccountInfos } from '../util'
|
|
7
|
+
|
|
8
|
+
export default function (server: Server, ctx: AppContext) {
|
|
9
|
+
server.tools.ozone.report.getReport({
|
|
10
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
11
|
+
handler: async ({ params, auth, req }) => {
|
|
12
|
+
const db = ctx.db
|
|
13
|
+
const modService = ctx.modService(db)
|
|
14
|
+
const labelers = ctx.reqLabelers(req)
|
|
15
|
+
|
|
16
|
+
const report = await getReportById(db, params.id)
|
|
17
|
+
if (!report) {
|
|
18
|
+
throw new InvalidRequestError(
|
|
19
|
+
`Report not found: ${params.id}`,
|
|
20
|
+
'NotFound',
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const queueService = ctx.queueService(db)
|
|
25
|
+
const teamService = ctx.teamService(db)
|
|
26
|
+
const [hydrated, actionEvents] = await Promise.all([
|
|
27
|
+
hydrateReportInfo(
|
|
28
|
+
[report],
|
|
29
|
+
modService.views,
|
|
30
|
+
(dids) => getPdsAccountInfos(ctx, dids),
|
|
31
|
+
(queueIds) => queueService.getViewsByIds(queueIds),
|
|
32
|
+
(dids) => teamService.viewByDids(dids),
|
|
33
|
+
labelers,
|
|
34
|
+
),
|
|
35
|
+
Array.isArray(report.actionEventIds) && report.actionEventIds.length
|
|
36
|
+
? modService.getEventsByIds(report.actionEventIds as number[])
|
|
37
|
+
: Promise.resolve([]),
|
|
38
|
+
])
|
|
39
|
+
|
|
40
|
+
const actions = actionEvents.map((evt) =>
|
|
41
|
+
modService.views.formatEvent(evt),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
encoding: 'application/json',
|
|
46
|
+
body: buildReportView(
|
|
47
|
+
report,
|
|
48
|
+
hydrated,
|
|
49
|
+
auth.credentials.isModerator,
|
|
50
|
+
actions,
|
|
51
|
+
),
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
}
|