@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atproto/ozone
|
|
2
2
|
|
|
3
|
+
## 0.1.174
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4661](https://github.com/bluesky-social/atproto/pull/4661) [`d05b76c`](https://github.com/bluesky-social/atproto/commit/d05b76cdb59e5bf0af739d1dcbe54df5e7faa7b3) Thanks [@foysalit](https://github.com/foysalit)! - Introduce report based moderation flow in ozone
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`d05b76c`](https://github.com/bluesky-social/atproto/commit/d05b76cdb59e5bf0af739d1dcbe54df5e7faa7b3)]:
|
|
10
|
+
- @atproto/api@0.19.16
|
|
11
|
+
|
|
3
12
|
## 0.1.173
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAqEnC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAA;AAElC,OAAO,KAAK,SAAS,MAAM,cAAc,CAAA;AAEzC,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,UAqEvD"}
|
package/dist/api/index.js
CHANGED
|
@@ -62,7 +62,27 @@ const queryStatuses_1 = __importDefault(require("./moderation/queryStatuses"));
|
|
|
62
62
|
const scheduleAction_1 = __importDefault(require("./moderation/scheduleAction"));
|
|
63
63
|
const searchRepos_1 = __importDefault(require("./moderation/searchRepos"));
|
|
64
64
|
const proxied_1 = __importDefault(require("./proxied"));
|
|
65
|
+
const assignModerator_1 = __importDefault(require("./queue/assignModerator"));
|
|
66
|
+
const createQueue_1 = __importDefault(require("./queue/createQueue"));
|
|
67
|
+
const deleteQueue_1 = __importDefault(require("./queue/deleteQueue"));
|
|
68
|
+
const getAssignments_1 = __importDefault(require("./queue/getAssignments"));
|
|
69
|
+
const listQueues_1 = __importDefault(require("./queue/listQueues"));
|
|
70
|
+
const routeReports_1 = __importDefault(require("./queue/routeReports"));
|
|
71
|
+
const unassignModerator_1 = __importDefault(require("./queue/unassignModerator"));
|
|
72
|
+
const updateQueue_1 = __importDefault(require("./queue/updateQueue"));
|
|
73
|
+
const assignModerator_2 = __importDefault(require("./report/assignModerator"));
|
|
74
|
+
const createActivity_1 = __importDefault(require("./report/createActivity"));
|
|
65
75
|
const createReport_1 = __importDefault(require("./report/createReport"));
|
|
76
|
+
const getAssignments_2 = __importDefault(require("./report/getAssignments"));
|
|
77
|
+
const getHistoricalStats_1 = __importDefault(require("./report/getHistoricalStats"));
|
|
78
|
+
const getLatestReport_1 = __importDefault(require("./report/getLatestReport"));
|
|
79
|
+
const getLiveStats_1 = __importDefault(require("./report/getLiveStats"));
|
|
80
|
+
const getReport_1 = __importDefault(require("./report/getReport"));
|
|
81
|
+
const listActivities_1 = __importDefault(require("./report/listActivities"));
|
|
82
|
+
const queryReports_1 = __importDefault(require("./report/queryReports"));
|
|
83
|
+
const reassignQueue_1 = __importDefault(require("./report/reassignQueue"));
|
|
84
|
+
const refreshStats_1 = __importDefault(require("./report/refreshStats"));
|
|
85
|
+
const unassignModerator_2 = __importDefault(require("./report/unassignModerator"));
|
|
66
86
|
const addRule_1 = __importDefault(require("./safelink/addRule"));
|
|
67
87
|
const queryEvents_2 = __importDefault(require("./safelink/queryEvents"));
|
|
68
88
|
const queryRules_1 = __importDefault(require("./safelink/queryRules"));
|
|
@@ -97,6 +117,8 @@ function default_1(server, ctx) {
|
|
|
97
117
|
(0, getRepos_1.default)(server, ctx);
|
|
98
118
|
(0, getEvent_1.default)(server, ctx);
|
|
99
119
|
(0, queryEvents_1.default)(server, ctx);
|
|
120
|
+
(0, getReport_1.default)(server, ctx);
|
|
121
|
+
(0, queryReports_1.default)(server, ctx);
|
|
100
122
|
(0, queryStatuses_1.default)(server, ctx);
|
|
101
123
|
(0, queryLabels_1.default)(server, ctx);
|
|
102
124
|
(0, subscribeLabels_1.default)(server, ctx);
|
|
@@ -112,6 +134,10 @@ function default_1(server, ctx) {
|
|
|
112
134
|
(0, chat_1.default)(server, ctx);
|
|
113
135
|
(0, proxied_1.default)(server, ctx);
|
|
114
136
|
(0, getConfig_1.default)(server, ctx);
|
|
137
|
+
(0, createQueue_1.default)(server, ctx);
|
|
138
|
+
(0, listQueues_1.default)(server, ctx);
|
|
139
|
+
(0, updateQueue_1.default)(server, ctx);
|
|
140
|
+
(0, deleteQueue_1.default)(server, ctx);
|
|
115
141
|
(0, addValues_1.default)(server, ctx);
|
|
116
142
|
(0, getValues_1.default)(server, ctx);
|
|
117
143
|
(0, querySets_1.default)(server, ctx);
|
|
@@ -135,6 +161,20 @@ function default_1(server, ctx) {
|
|
|
135
161
|
(0, scheduleAction_1.default)(server, ctx);
|
|
136
162
|
(0, listScheduledActions_1.default)(server, ctx);
|
|
137
163
|
(0, cancelScheduledActions_1.default)(server, ctx);
|
|
164
|
+
(0, routeReports_1.default)(server, ctx);
|
|
165
|
+
(0, getLiveStats_1.default)(server, ctx);
|
|
166
|
+
(0, getHistoricalStats_1.default)(server, ctx);
|
|
167
|
+
(0, refreshStats_1.default)(server, ctx);
|
|
168
|
+
(0, assignModerator_1.default)(server, ctx);
|
|
169
|
+
(0, unassignModerator_1.default)(server, ctx);
|
|
170
|
+
(0, getAssignments_1.default)(server, ctx);
|
|
171
|
+
(0, getLatestReport_1.default)(server, ctx);
|
|
172
|
+
(0, assignModerator_2.default)(server, ctx);
|
|
173
|
+
(0, unassignModerator_2.default)(server, ctx);
|
|
174
|
+
(0, getAssignments_2.default)(server, ctx);
|
|
175
|
+
(0, createActivity_1.default)(server, ctx);
|
|
176
|
+
(0, listActivities_1.default)(server, ctx);
|
|
177
|
+
(0, reassignQueue_1.default)(server, ctx);
|
|
138
178
|
return server;
|
|
139
179
|
}
|
|
140
180
|
//# sourceMappingURL=index.js.map
|
package/dist/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,4BAiDC;AArGD,kDAAyB;AACzB,oFAA2D;AAC3D,oFAA2D;AAC3D,kFAAyD;AACzD,oFAA2D;AAC3D,sEAA6C;AAC7C,sEAA6C;AAC7C,8EAAqD;AACrD,iGAAwE;AACxE,uEAA8C;AAC9C,yFAAgE;AAChE,qEAA4C;AAC5C,uEAAmD;AACnD,yEAAqD;AACrD,mEAA0C;AAC1C,qFAA4D;AAC5D,qEAA4C;AAC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AAA,4BAAkB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B,IAAA,6BAAmB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAChC,IAAA,2BAAiB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9B,IAAA,iBAAe,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5B,IAAA,oBAAkB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B,IAAA,oBAAkB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B,IAAA,qBAAmB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAChC,IAAA,oBAAkB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B,IAAA,4BAAkB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B,IAAA,wBAAc,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,IAAA,8BAAoB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACjC,IAAA,gCAAsB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { AppContext } from '../context'\nimport { Server } from '../lexicon'\nimport chat from './chat'\nimport createTemplate from './communication/createTemplate'\nimport deleteTemplate from './communication/deleteTemplate'\nimport listTemplates from './communication/listTemplates'\nimport updateTemplate from './communication/updateTemplate'\nimport fetchLabels from './label/fetchLabels'\nimport queryLabels from './label/queryLabels'\nimport subscribeLabels from './label/subscribeLabels'\nimport cancelScheduledActions from './moderation/cancelScheduledActions'\nimport emitEvent from './moderation/emitEvent'\nimport getAccountTimeline from './moderation/getAccountTimeline'\nimport getEvent from './moderation/getEvent'\nimport adminGetRecord from './moderation/getRecord'\nimport adminGetRecords from './moderation/getRecords'\nimport getRepo from './moderation/getRepo'\nimport getReporterStats from './moderation/getReporterStats'\nimport getRepos from './moderation/getRepos'\nimport getSubjects from './moderation/getSubjects'\nimport listScheduledActions from './moderation/listScheduledActions'\nimport queryEvents from './moderation/queryEvents'\nimport queryStatuses from './moderation/queryStatuses'\nimport scheduleAction from './moderation/scheduleAction'\nimport searchRepos from './moderation/searchRepos'\nimport proxied from './proxied'\nimport createReport from './report/createReport'\nimport addSafelinkRule from './safelink/addRule'\nimport querySafelinkEvents from './safelink/queryEvents'\nimport querySafelinkRules from './safelink/queryRules'\nimport removeSafelinkRule from './safelink/removeRule'\nimport updateSafelinkRule from './safelink/updateRule'\nimport getConfig from './server/getConfig'\nimport setAddValues from './set/addValues'\nimport deleteSet from './set/deleteSet'\nimport setDeleteValues from './set/deleteValues'\nimport setGetValues from './set/getValues'\nimport querySets from './set/querySets'\nimport upsertSet from './set/upsertSet'\nimport listOptions from './setting/listOptions'\nimport removeOptions from './setting/removeOptions'\nimport upsertOption from './setting/upsertOption'\nimport addMember from './team/addMember'\nimport deleteMember from './team/deleteMember'\nimport listMembers from './team/listMembers'\nimport updateMember from './team/updateMember'\nimport grantVerifications from './verification/grantVerifications'\nimport listVerifications from './verification/listVerifications'\nimport revokeVerifications from './verification/revokeVerifications'\n\nexport * as health from './health'\n\nexport * as wellKnown from './well-known'\n\nexport default function (server: Server, ctx: AppContext) {\n createReport(server, ctx)\n emitEvent(server, ctx)\n searchRepos(server, ctx)\n adminGetRecord(server, ctx)\n adminGetRecords(server, ctx)\n getRepo(server, ctx)\n getRepos(server, ctx)\n getEvent(server, ctx)\n queryEvents(server, ctx)\n queryStatuses(server, ctx)\n queryLabels(server, ctx)\n subscribeLabels(server, ctx)\n fetchLabels(server, ctx)\n listTemplates(server, ctx)\n createTemplate(server, ctx)\n updateTemplate(server, ctx)\n deleteTemplate(server, ctx)\n listMembers(server, ctx)\n addMember(server, ctx)\n updateMember(server, ctx)\n deleteMember(server, ctx)\n chat(server, ctx)\n proxied(server, ctx)\n getConfig(server, ctx)\n setAddValues(server, ctx)\n setGetValues(server, ctx)\n querySets(server, ctx)\n upsertSet(server, ctx)\n setDeleteValues(server, ctx)\n deleteSet(server, ctx)\n upsertOption(server, ctx)\n listOptions(server, ctx)\n removeOptions(server, ctx)\n getReporterStats(server, ctx)\n getSubjects(server, ctx)\n grantVerifications(server, ctx)\n revokeVerifications(server, ctx)\n listVerifications(server, ctx)\n addSafelinkRule(server, ctx)\n updateSafelinkRule(server, ctx)\n removeSafelinkRule(server, ctx)\n querySafelinkEvents(server, ctx)\n querySafelinkRules(server, ctx)\n getAccountTimeline(server, ctx)\n scheduleAction(server, ctx)\n listScheduledActions(server, ctx)\n cancelScheduledActions(server, ctx)\n return server\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,4BAqEC;AA7ID,kDAAyB;AACzB,oFAA2D;AAC3D,oFAA2D;AAC3D,kFAAyD;AACzD,oFAA2D;AAC3D,sEAA6C;AAC7C,sEAA6C;AAC7C,8EAAqD;AACrD,iGAAwE;AACxE,uEAA8C;AAC9C,yFAAgE;AAChE,qEAA4C;AAC5C,uEAAmD;AACnD,yEAAqD;AACrD,mEAA0C;AAC1C,qFAA4D;AAC5D,qEAA4C;AAC5C,2EAAkD;AAClD,6FAAoE;AACpE,2EAAkD;AAClD,+EAAsD;AACtD,iFAAwD;AACxD,2EAAkD;AAClD,wDAA+B;AAC/B,8EAA0D;AAC1D,sEAA6C;AAC7C,sEAA6C;AAC7C,4EAAwD;AACxD,oEAA2C;AAC3C,wEAA+C;AAC/C,kFAA8D;AAC9D,sEAA6C;AAC7C,+EAA4D;AAC5D,6EAAoD;AACpD,yEAAgD;AAChD,6EAA0D;AAC1D,qFAA4D;AAC5D,+EAAsD;AACtD,yEAAgD;AAChD,mEAA0C;AAC1C,6EAAoD;AACpD,yEAAgD;AAChD,2EAAkD;AAClD,yEAAgD;AAChD,mFAAgE;AAChE,iEAAgD;AAChD,yEAAwD;AACxD,uEAAsD;AACtD,uEAAsD;AACtD,uEAA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,yBAAe,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5B,IAAA,yBAAqB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAClC,IAAA,2BAAuB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,IAAA,wBAAoB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACjC,IAAA,wBAAc,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,IAAA,wBAAc,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,IAAA,uBAAa,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC1B,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { AppContext } from '../context'\nimport { Server } from '../lexicon'\nimport chat from './chat'\nimport createTemplate from './communication/createTemplate'\nimport deleteTemplate from './communication/deleteTemplate'\nimport listTemplates from './communication/listTemplates'\nimport updateTemplate from './communication/updateTemplate'\nimport fetchLabels from './label/fetchLabels'\nimport queryLabels from './label/queryLabels'\nimport subscribeLabels from './label/subscribeLabels'\nimport cancelScheduledActions from './moderation/cancelScheduledActions'\nimport emitEvent from './moderation/emitEvent'\nimport getAccountTimeline from './moderation/getAccountTimeline'\nimport getEvent from './moderation/getEvent'\nimport adminGetRecord from './moderation/getRecord'\nimport adminGetRecords from './moderation/getRecords'\nimport getRepo from './moderation/getRepo'\nimport getReporterStats from './moderation/getReporterStats'\nimport getRepos from './moderation/getRepos'\nimport getSubjects from './moderation/getSubjects'\nimport listScheduledActions from './moderation/listScheduledActions'\nimport queryEvents from './moderation/queryEvents'\nimport queryStatuses from './moderation/queryStatuses'\nimport scheduleAction from './moderation/scheduleAction'\nimport searchRepos from './moderation/searchRepos'\nimport proxied from './proxied'\nimport assignQueueModerator from './queue/assignModerator'\nimport createQueue from './queue/createQueue'\nimport deleteQueue from './queue/deleteQueue'\nimport getQueueAssignments from './queue/getAssignments'\nimport listQueues from './queue/listQueues'\nimport routeReports from './queue/routeReports'\nimport unassignQueueModerator from './queue/unassignModerator'\nimport updateQueue from './queue/updateQueue'\nimport assignReportModerator from './report/assignModerator'\nimport createActivity from './report/createActivity'\nimport createReport from './report/createReport'\nimport getReportAssignments from './report/getAssignments'\nimport getHistoricalStats from './report/getHistoricalStats'\nimport getLatestReport from './report/getLatestReport'\nimport getLiveStats from './report/getLiveStats'\nimport getReport from './report/getReport'\nimport listActivities from './report/listActivities'\nimport queryReports from './report/queryReports'\nimport reassignQueue from './report/reassignQueue'\nimport refreshStats from './report/refreshStats'\nimport unassignReportModerator from './report/unassignModerator'\nimport addSafelinkRule from './safelink/addRule'\nimport querySafelinkEvents from './safelink/queryEvents'\nimport querySafelinkRules from './safelink/queryRules'\nimport removeSafelinkRule from './safelink/removeRule'\nimport updateSafelinkRule from './safelink/updateRule'\nimport getConfig from './server/getConfig'\nimport setAddValues from './set/addValues'\nimport deleteSet from './set/deleteSet'\nimport setDeleteValues from './set/deleteValues'\nimport setGetValues from './set/getValues'\nimport querySets from './set/querySets'\nimport upsertSet from './set/upsertSet'\nimport listOptions from './setting/listOptions'\nimport removeOptions from './setting/removeOptions'\nimport upsertOption from './setting/upsertOption'\nimport addMember from './team/addMember'\nimport deleteMember from './team/deleteMember'\nimport listMembers from './team/listMembers'\nimport updateMember from './team/updateMember'\nimport grantVerifications from './verification/grantVerifications'\nimport listVerifications from './verification/listVerifications'\nimport revokeVerifications from './verification/revokeVerifications'\n\nexport * as health from './health'\n\nexport * as wellKnown from './well-known'\n\nexport default function (server: Server, ctx: AppContext) {\n createReport(server, ctx)\n emitEvent(server, ctx)\n searchRepos(server, ctx)\n adminGetRecord(server, ctx)\n adminGetRecords(server, ctx)\n getRepo(server, ctx)\n getRepos(server, ctx)\n getEvent(server, ctx)\n queryEvents(server, ctx)\n getReport(server, ctx)\n queryReports(server, ctx)\n queryStatuses(server, ctx)\n queryLabels(server, ctx)\n subscribeLabels(server, ctx)\n fetchLabels(server, ctx)\n listTemplates(server, ctx)\n createTemplate(server, ctx)\n updateTemplate(server, ctx)\n deleteTemplate(server, ctx)\n listMembers(server, ctx)\n addMember(server, ctx)\n updateMember(server, ctx)\n deleteMember(server, ctx)\n chat(server, ctx)\n proxied(server, ctx)\n getConfig(server, ctx)\n createQueue(server, ctx)\n listQueues(server, ctx)\n updateQueue(server, ctx)\n deleteQueue(server, ctx)\n setAddValues(server, ctx)\n setGetValues(server, ctx)\n querySets(server, ctx)\n upsertSet(server, ctx)\n setDeleteValues(server, ctx)\n deleteSet(server, ctx)\n upsertOption(server, ctx)\n listOptions(server, ctx)\n removeOptions(server, ctx)\n getReporterStats(server, ctx)\n getSubjects(server, ctx)\n grantVerifications(server, ctx)\n revokeVerifications(server, ctx)\n listVerifications(server, ctx)\n addSafelinkRule(server, ctx)\n updateSafelinkRule(server, ctx)\n removeSafelinkRule(server, ctx)\n querySafelinkEvents(server, ctx)\n querySafelinkRules(server, ctx)\n getAccountTimeline(server, ctx)\n scheduleAction(server, ctx)\n listScheduledActions(server, ctx)\n cancelScheduledActions(server, ctx)\n routeReports(server, ctx)\n getLiveStats(server, ctx)\n getHistoricalStats(server, ctx)\n refreshStats(server, ctx)\n assignQueueModerator(server, ctx)\n unassignQueueModerator(server, ctx)\n getQueueAssignments(server, ctx)\n getLatestReport(server, ctx)\n assignReportModerator(server, ctx)\n unassignReportModerator(server, ctx)\n getReportAssignments(server, ctx)\n createActivity(server, ctx)\n listActivities(server, ctx)\n reassignQueue(server, ctx)\n return server\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitEvent.d.ts","sourceRoot":"","sources":["../../../src/api/moderation/emitEvent.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"emitEvent.d.ts","sourceRoot":"","sources":["../../../src/api/moderation/emitEvent.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAuWtC,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QA6CvD"}
|
|
@@ -6,6 +6,7 @@ const xrpc_server_1 = require("@atproto/xrpc-server");
|
|
|
6
6
|
const lexicons_1 = require("../../lexicon/lexicons");
|
|
7
7
|
const defs_2 = require("../../lexicon/types/tools/ozone/moderation/defs");
|
|
8
8
|
const logger_1 = require("../../logger");
|
|
9
|
+
const report_1 = require("../../mod-service/report");
|
|
9
10
|
const subject_1 = require("../../mod-service/subject");
|
|
10
11
|
const tag_service_1 = require("../../tag-service");
|
|
11
12
|
const util_1 = require("../../tag-service/util");
|
|
@@ -150,6 +151,16 @@ const handleModerationEvent = async ({ ctx, input, auth, }) => {
|
|
|
150
151
|
throw new xrpc_server_1.InvalidRequestError(`An event with the same external ID already exists for the subject.`, 'DuplicateExternalId');
|
|
151
152
|
}
|
|
152
153
|
}
|
|
154
|
+
// Validate reportAction if provided (actual processing happens after event is logged)
|
|
155
|
+
if (input.body.reportAction) {
|
|
156
|
+
// Validate that at least one targeting criteria is provided
|
|
157
|
+
const { reportAction } = input.body;
|
|
158
|
+
if (!reportAction.ids?.length &&
|
|
159
|
+
!reportAction.types?.length &&
|
|
160
|
+
!reportAction.all) {
|
|
161
|
+
throw new xrpc_server_1.InvalidRequestError('reportAction must specify ids, types, or all');
|
|
162
|
+
}
|
|
163
|
+
}
|
|
153
164
|
const result = await moderationTxn.logEvent({
|
|
154
165
|
event,
|
|
155
166
|
subject,
|
|
@@ -157,6 +168,26 @@ const handleModerationEvent = async ({ ctx, input, auth, }) => {
|
|
|
157
168
|
modTool: input.body.modTool,
|
|
158
169
|
externalId,
|
|
159
170
|
});
|
|
171
|
+
// Update reports if reportAction was provided
|
|
172
|
+
if (input.body.reportAction) {
|
|
173
|
+
const subjectUri = subject.isRecord() ? subject.uri : null;
|
|
174
|
+
try {
|
|
175
|
+
await (0, report_1.processReportAction)({
|
|
176
|
+
db: dbTxn,
|
|
177
|
+
reportAction: input.body.reportAction,
|
|
178
|
+
subjectDid: subject.did,
|
|
179
|
+
subjectUri,
|
|
180
|
+
eventId: result.event.id,
|
|
181
|
+
eventType: event.$type,
|
|
182
|
+
createdBy,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
throw new xrpc_server_1.InvalidRequestError(err instanceof Error
|
|
187
|
+
? err.message
|
|
188
|
+
: 'Failed to process report action');
|
|
189
|
+
}
|
|
190
|
+
}
|
|
160
191
|
const tagService = new tag_service_1.TagService(subject, result.subjectStatus, ctx.cfg.service.did, moderationTxn);
|
|
161
192
|
const initialTags = (0, defs_2.isModEventReport)(event)
|
|
162
193
|
? [(0, util_1.getTagForReport)(event.reportType)]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitEvent.js","sourceRoot":"","sources":["../../../src/api/moderation/emitEvent.ts"],"names":[],"mappings":";;AAyUA,4BA6CC;AAtXD,qFAA6F;AAC7F,sDAI6B;AAI7B,qDAA4C;AAC5C,0EAewD;AAExD,yCAAyC;AACzC,uDAA4D;AAE5D,mDAA8C;AAC9C,iDAAwD;AACxD,qCAAsC;AACtC,kCAAsC;AACtC,iCAAmE;AAEnE,MAAM,qBAAqB,GAAG,KAAK,EAAE,EACnC,GAAG,EACH,KAAK,EACL,IAAI,GAKL,EAAE,EAAE;IACH,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAA;IAC/B,MAAM,SAAS,GACb,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,WAAW;QACnC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG;QACtB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAA;IAC1B,MAAM,EAAE,GAAG,GAAG,CAAC,EAAE,CAAA;IACjB,MAAM,iBAAiB,GAAG,GAAG,CAAC,UAAU,CAAC,E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ACH,CAAC,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA","sourcesContent":["import { isModEventDivert } from '@atproto/api/dist/client/types/tools/ozone/moderation/defs'\nimport {\n AuthRequiredError,\n ForbiddenError,\n InvalidRequestError,\n} from '@atproto/xrpc-server'\nimport { AdminTokenOutput, ModeratorOutput } from '../../auth-verifier'\nimport { AppContext } from '../../context'\nimport { Server } from '../../lexicon'\nimport { ids } from '../../lexicon/lexicons'\nimport {\n ModEventTag,\n isAgeAssuranceEvent,\n isAgeAssuranceOverrideEvent,\n isAgeAssurancePurgeEvent,\n isModEventAcknowledge,\n isModEventEmail,\n isModEventLabel,\n isModEventMuteReporter,\n isModEventReport,\n isModEventReverseTakedown,\n isModEventTag,\n isModEventTakedown,\n isModEventUnmuteReporter,\n isRevokeAccountCredentialsEvent,\n} from '../../lexicon/types/tools/ozone/moderation/defs'\nimport { HandlerInput } from '../../lexicon/types/tools/ozone/moderation/emitEvent'\nimport { httpLogger } from '../../logger'\nimport { subjectFromInput } from '../../mod-service/subject'\nimport { SettingService } from '../../setting/service'\nimport { TagService } from '../../tag-service'\nimport { getTagForReport } from '../../tag-service/util'\nimport { retryHttp } from '../../util'\nimport { getEventType } from '../util'\nimport { assertProtectedTagAction, getProtectedTags } from './util'\n\nconst handleModerationEvent = async ({\n ctx,\n input,\n auth,\n}: {\n ctx: AppContext\n input: HandlerInput\n auth: ModeratorOutput | AdminTokenOutput\n}) => {\n const access = auth.credentials\n const createdBy =\n auth.credentials.type === 'moderator'\n ? auth.credentials.iss\n : input.body.createdBy\n const db = ctx.db\n const moderationService = ctx.modService(db)\n const settingService = ctx.settingService(db)\n const { event, externalId } = input.body\n const isAcknowledgeEvent = isModEventAcknowledge(event)\n const isTakedownEvent = isModEventTakedown(event)\n const isReverseTakedownEvent = isModEventReverseTakedown(event)\n const isLabelEvent = isModEventLabel(event)\n const subject = subjectFromInput(\n input.body.subject,\n input.body.subjectBlobCids,\n )\n\n if (isAgeAssuranceEvent(event) && !subject.isRepo()) {\n throw new InvalidRequestError('Invalid subject type')\n }\n\n if (isAgeAssuranceOverrideEvent(event)) {\n if (!subject.isRepo()) {\n throw new InvalidRequestError('Invalid subject type')\n }\n if (!auth.credentials.isModerator) {\n throw new AuthRequiredError(\n 'Must be a full moderator to override age assurance',\n )\n }\n }\n\n if (isAgeAssurancePurgeEvent(event)) {\n if (!subject.isRepo()) {\n throw new InvalidRequestError('Invalid subject type')\n }\n if (!auth.credentials.isModerator) {\n throw new ForbiddenError(\n 'Must be a moderator to purge age assurance events',\n )\n }\n }\n\n if (isRevokeAccountCredentialsEvent(event)) {\n if (!subject.isRepo()) {\n throw new InvalidRequestError('Invalid subject type')\n }\n\n if (!auth.credentials.isAdmin) {\n throw new AuthRequiredError(\n 'Must be an admin to revoke account credentials',\n )\n }\n\n if (!ctx.pdsAgent) {\n throw new InvalidRequestError('PDS not configured')\n }\n\n await ctx.pdsAgent.com.atproto.temp.revokeAccountCredentials(\n { account: subject.did },\n await ctx.pdsAuth(ids.ComAtprotoTempRevokeAccountCredentials),\n )\n }\n\n // if less than moderator access then can only take ack and escalation actions\n if (isTakedownEvent || isReverseTakedownEvent) {\n if (!access.isModerator) {\n throw new AuthRequiredError(\n 'Must be a full moderator to take this type of action',\n )\n }\n\n // Non admins should not be able to take down feed generators\n if (\n !access.isAdmin &&\n subject.recordPath?.includes('app.bsky.feed.generator/')\n ) {\n throw new AuthRequiredError(\n 'Must be a full admin to take this type of action on feed generators',\n )\n }\n }\n // if less than moderator access then can not apply labels\n if (!access.isModerator && isLabelEvent) {\n throw new AuthRequiredError('Must be a full moderator to label content')\n }\n\n if (isLabelEvent) {\n validateLabels([\n ...(event.createLabelVals ?? []),\n ...(event.negateLabelVals ?? []),\n ])\n }\n\n const isTakedownOrReverseTakedownEvent =\n isTakedownEvent || isReverseTakedownEvent\n if (isTakedownOrReverseTakedownEvent || isLabelEvent) {\n const status = await moderationService.getStatus(subject)\n\n if (status?.takendown && isTakedownEvent) {\n throw new InvalidRequestError(`Subject is already taken down`)\n }\n\n if (!status?.takendown && isReverseTakedownEvent) {\n throw new InvalidRequestError(`Subject is not taken down`)\n }\n\n if (status?.tags?.length) {\n const protectedTags = await getProtectedTags(\n settingService,\n ctx.cfg.service.did,\n )\n\n if (protectedTags) {\n assertProtectedTagAction({\n protectedTags,\n subjectTags: status.tags,\n actionAuthor: createdBy,\n isAdmin: auth.credentials.isAdmin,\n isModerator: auth.credentials.isModerator,\n isTriage: auth.credentials.isTriage,\n })\n }\n }\n\n if (status?.takendown && isReverseTakedownEvent && subject.isRecord()) {\n // due to the way blob status is modeled, we should reverse takedown on all\n // blobs for the record being restored, which aren't taken down on another record.\n subject.blobCids = status.blobCids ?? []\n }\n }\n\n if (isModEventEmail(event) && event.content) {\n // sending email prior to logging the event to avoid a long transaction below\n if (!subject.isRepo()) {\n throw new InvalidRequestError('Email can only be sent to a repo subject')\n }\n const { content, subjectLine } = event\n // on error, don't fail the whole event. instead, log the event data with isDelivered false\n try {\n await retryHttp(() =>\n ctx.modService(db).sendEmail({\n subject: subjectLine,\n content,\n recipientDid: subject.did,\n }),\n )\n event.isDelivered = true\n } catch (err) {\n event.isDelivered = false\n httpLogger.error({ err, event }, 'failed to send mod event email')\n }\n }\n\n if (isModEventDivert(event) && subject.isRecord()) {\n if (!ctx.blobDiverter) {\n throw new InvalidRequestError(\n 'BlobDiverter not configured for this service',\n )\n }\n await ctx.blobDiverter.uploadBlobOnService(subject.info())\n }\n\n if (\n (isModEventMuteReporter(event) || isModEventUnmuteReporter(event)) &&\n !subject.isRepo()\n ) {\n throw new InvalidRequestError('Subject must be a repo when muting reporter')\n }\n\n if (isModEventTag(event)) {\n await assertTagAuth(settingService, ctx.cfg.service.did, event, auth)\n }\n\n if (isModEventReport(event)) {\n await ctx.moderationServiceProfile().validateReasonType(event.reportType)\n }\n\n const moderationEvent = await db.transaction(async (dbTxn) => {\n const moderationTxn = ctx.modService(dbTxn)\n\n if (externalId) {\n const existingEvent = await moderationTxn.getEventByExternalId(\n getEventType(event.$type),\n externalId,\n subject,\n )\n\n if (existingEvent) {\n throw new InvalidRequestError(\n `An event with the same external ID already exists for the subject.`,\n 'DuplicateExternalId',\n )\n }\n }\n\n const result = await moderationTxn.logEvent({\n event,\n subject,\n createdBy,\n modTool: input.body.modTool,\n externalId,\n })\n\n const tagService = new TagService(\n subject,\n result.subjectStatus,\n ctx.cfg.service.did,\n moderationTxn,\n )\n\n const initialTags = isModEventReport(event)\n ? [getTagForReport(event.reportType)]\n : undefined\n await tagService.evaluateForSubject(initialTags)\n\n if (subject.isRepo()) {\n if (isTakedownEvent) {\n const isSuspend = !!result.event.durationInHours\n await moderationTxn.takedownRepo(\n subject,\n result.event.id,\n new Set(\n result.event.meta?.targetServices\n ? `${result.event.meta.targetServices}`.split(',')\n : undefined,\n ),\n isSuspend,\n )\n } else if (isReverseTakedownEvent) {\n await moderationTxn.reverseTakedownRepo(subject)\n }\n }\n\n if (subject.isRecord()) {\n if (isTakedownEvent) {\n await moderationTxn.takedownRecord(\n subject,\n result.event.id,\n new Set(\n result.event.meta?.targetServices\n ? `${result.event.meta.targetServices}`.split(',')\n : undefined,\n ),\n )\n } else if (isReverseTakedownEvent) {\n await moderationTxn.reverseTakedownRecord(subject)\n }\n }\n\n if (\n (isTakedownEvent || isAcknowledgeEvent) &&\n result.event.meta?.acknowledgeAccountSubjects\n ) {\n await moderationTxn.resolveSubjectsForAccount(\n subject.did,\n createdBy,\n result.event,\n )\n }\n\n if (isLabelEvent) {\n await moderationTxn.formatAndCreateLabels(\n result.event.subjectUri ?? result.event.subjectDid,\n result.event.subjectCid,\n {\n create: result.event.createLabelVals?.length\n ? result.event.createLabelVals.split(' ')\n : undefined,\n negate: result.event.negateLabelVals?.length\n ? result.event.negateLabelVals.split(' ')\n : undefined,\n },\n result.event.durationInHours ?? undefined,\n )\n }\n\n return result.event\n })\n\n return moderationService.views.formatEvent(moderationEvent)\n}\n\nexport default function (server: Server, ctx: AppContext) {\n server.tools.ozone.moderation.emitEvent({\n auth: ctx.authVerifier.modOrAdminToken,\n handler: async ({ input, auth }) => {\n try {\n const moderationEvent = await handleModerationEvent({\n input,\n auth,\n ctx,\n })\n\n // On divert events, we need to automatically take down the blobs\n if (isModEventDivert(input.body.event)) {\n await handleModerationEvent({\n auth,\n ctx,\n input: {\n ...input,\n body: {\n ...input.body,\n event: {\n ...input.body.event,\n $type: 'tools.ozone.moderation.defs#modEventTakedown',\n comment:\n '[DIVERT_SIDE_EFFECT]: Automatically taking down after divert event',\n },\n modTool: input.body.modTool,\n },\n },\n })\n }\n\n return {\n encoding: 'application/json',\n body: moderationEvent,\n }\n } catch (err) {\n httpLogger.error(\n { err, body: input.body },\n 'failed to emit moderation event',\n )\n throw err\n }\n },\n })\n}\n\nconst assertTagAuth = async (\n settingService: SettingService,\n serviceDid: string,\n event: ModEventTag,\n auth: ModeratorOutput | AdminTokenOutput,\n) => {\n // admins can add/remove any tag\n if (auth.credentials.isAdmin) return\n\n const protectedTags = await getProtectedTags(settingService, serviceDid)\n\n if (!protectedTags) {\n return\n }\n\n for (const tag of Object.keys(protectedTags)) {\n if (event.add.includes(tag) || event.remove.includes(tag)) {\n // if specific moderators are configured to manage this tag but the current user\n // is not one of them, then throw an error\n const configuredModerators = protectedTags[tag]?.['moderators']\n if (\n configuredModerators &&\n !configuredModerators.includes(auth.credentials.iss)\n ) {\n throw new InvalidRequestError(`Not allowed to manage tag: ${tag}`)\n }\n\n const configuredRoles = protectedTags[tag]?.['roles']\n if (configuredRoles) {\n // admins can already do everything so we only check for moderator and triage role config\n if (\n auth.credentials.isModerator &&\n !configuredRoles.includes('tools.ozone.team.defs#roleModerator')\n ) {\n throw new InvalidRequestError(\n `Can not manage tag ${tag} with moderator role`,\n )\n } else if (\n auth.credentials.isTriage &&\n !configuredRoles.includes('tools.ozone.team.defs#roleTriage')\n ) {\n throw new InvalidRequestError(\n `Can not manage tag ${tag} with triage role`,\n )\n }\n }\n }\n }\n}\n\nconst validateLabels = (labels: string[]) => {\n for (const label of labels) {\n for (const char of badChars) {\n if (label.includes(char)) {\n throw new InvalidRequestError(`Invalid label: ${label}`)\n }\n }\n }\n}\n\nconst badChars = [' ', ',', ';', `'`, `\"`]\n"]}
|
|
1
|
+
{"version":3,"file":"emitEvent.js","sourceRoot":"","sources":["../../../src/api/moderation/emitEvent.ts"],"names":[],"mappings":";;AA+WA,4BA6CC;AA5ZD,qFAA6F;AAC7F,sDAI6B;AAI7B,qDAA4C;AAC5C,0EAewD;AAExD,yCAAyC;AACzC,qDAA8D;AAC9D,uDAA4D;AAE5D,mDAA8C;AAC9C,iDAAwD;AACxD,qCAAsC;AACtC,kCAAsC;AACtC,iCAAmE;AAEnE,MAAM,qBAAqB,GAAG,KAAK,EAAE,EACnC,GAAG,EACH,KAAK,EACL,IAAI,GAKL,EAAE,EAAE;IACH,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAA;IAC/B,MAAM,SAAS,GACb,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,WAAW;QACnC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG;QACtB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAA;IAC1B,MAAM,EAAE,GAAG,GAAG,CAAC,EAAE,CAAA;IACjB,MAAM,iBAAiB,GAAG,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;IAC5C,MAAM,cAAc,GAAG,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;IAC7C,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,IAAI,CAAA;IACxC,MAAM,kBAAkB,GAAG,IAAA,4BAAqB,EAAC,KAAK,CAAC,CAAA;IACvD,MAAM,eAAe,GAAG,IAAA,yBAAkB,EAAC,KAAK,CAAC,CAAA;IACjD,MAAM,sBAAsB,GAAG,IAAA,gCAAyB,EAAC,KAAK,CAA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Ae,CAAC,QAAQ,CAAC,qCAAqC,CAAC,EAChE,CAAC;oBACD,MAAM,IAAI,iCAAmB,CAC3B,sBAAsB,GAAG,sBAAsB,CAChD,CAAA;gBACH,CAAC;qBAAM,IACL,IAAI,CAAC,WAAW,CAAC,QAAQ;oBACzB,CAAC,eAAe,CAAC,QAAQ,CAAC,kCAAkC,CAAC,EAC7D,CAAC;oBACD,MAAM,IAAI,iCAAmB,CAC3B,sBAAsB,GAAG,mBAAmB,CAC7C,CAAA;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,MAAgB,EAAE,EAAE;IAC1C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;YAC5B,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzB,MAAM,IAAI,iCAAmB,CAAC,kBAAkB,KAAK,EAAE,CAAC,CAAA;YAC1D,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA","sourcesContent":["import { isModEventDivert } from '@atproto/api/dist/client/types/tools/ozone/moderation/defs'\nimport {\n AuthRequiredError,\n ForbiddenError,\n InvalidRequestError,\n} from '@atproto/xrpc-server'\nimport { AdminTokenOutput, ModeratorOutput } from '../../auth-verifier'\nimport { AppContext } from '../../context'\nimport { Server } from '../../lexicon'\nimport { ids } from '../../lexicon/lexicons'\nimport {\n ModEventTag,\n isAgeAssuranceEvent,\n isAgeAssuranceOverrideEvent,\n isAgeAssurancePurgeEvent,\n isModEventAcknowledge,\n isModEventEmail,\n isModEventLabel,\n isModEventMuteReporter,\n isModEventReport,\n isModEventReverseTakedown,\n isModEventTag,\n isModEventTakedown,\n isModEventUnmuteReporter,\n isRevokeAccountCredentialsEvent,\n} from '../../lexicon/types/tools/ozone/moderation/defs'\nimport { HandlerInput } from '../../lexicon/types/tools/ozone/moderation/emitEvent'\nimport { httpLogger } from '../../logger'\nimport { processReportAction } from '../../mod-service/report'\nimport { subjectFromInput } from '../../mod-service/subject'\nimport { SettingService } from '../../setting/service'\nimport { TagService } from '../../tag-service'\nimport { getTagForReport } from '../../tag-service/util'\nimport { retryHttp } from '../../util'\nimport { getEventType } from '../util'\nimport { assertProtectedTagAction, getProtectedTags } from './util'\n\nconst handleModerationEvent = async ({\n ctx,\n input,\n auth,\n}: {\n ctx: AppContext\n input: HandlerInput\n auth: ModeratorOutput | AdminTokenOutput\n}) => {\n const access = auth.credentials\n const createdBy =\n auth.credentials.type === 'moderator'\n ? auth.credentials.iss\n : input.body.createdBy\n const db = ctx.db\n const moderationService = ctx.modService(db)\n const settingService = ctx.settingService(db)\n const { event, externalId } = input.body\n const isAcknowledgeEvent = isModEventAcknowledge(event)\n const isTakedownEvent = isModEventTakedown(event)\n const isReverseTakedownEvent = isModEventReverseTakedown(event)\n const isLabelEvent = isModEventLabel(event)\n const subject = subjectFromInput(\n input.body.subject,\n input.body.subjectBlobCids,\n )\n\n if (isAgeAssuranceEvent(event) && !subject.isRepo()) {\n throw new InvalidRequestError('Invalid subject type')\n }\n\n if (isAgeAssuranceOverrideEvent(event)) {\n if (!subject.isRepo()) {\n throw new InvalidRequestError('Invalid subject type')\n }\n if (!auth.credentials.isModerator) {\n throw new AuthRequiredError(\n 'Must be a full moderator to override age assurance',\n )\n }\n }\n\n if (isAgeAssurancePurgeEvent(event)) {\n if (!subject.isRepo()) {\n throw new InvalidRequestError('Invalid subject type')\n }\n if (!auth.credentials.isModerator) {\n throw new ForbiddenError(\n 'Must be a moderator to purge age assurance events',\n )\n }\n }\n\n if (isRevokeAccountCredentialsEvent(event)) {\n if (!subject.isRepo()) {\n throw new InvalidRequestError('Invalid subject type')\n }\n\n if (!auth.credentials.isAdmin) {\n throw new AuthRequiredError(\n 'Must be an admin to revoke account credentials',\n )\n }\n\n if (!ctx.pdsAgent) {\n throw new InvalidRequestError('PDS not configured')\n }\n\n await ctx.pdsAgent.com.atproto.temp.revokeAccountCredentials(\n { account: subject.did },\n await ctx.pdsAuth(ids.ComAtprotoTempRevokeAccountCredentials),\n )\n }\n\n // if less than moderator access then can only take ack and escalation actions\n if (isTakedownEvent || isReverseTakedownEvent) {\n if (!access.isModerator) {\n throw new AuthRequiredError(\n 'Must be a full moderator to take this type of action',\n )\n }\n\n // Non admins should not be able to take down feed generators\n if (\n !access.isAdmin &&\n subject.recordPath?.includes('app.bsky.feed.generator/')\n ) {\n throw new AuthRequiredError(\n 'Must be a full admin to take this type of action on feed generators',\n )\n }\n }\n // if less than moderator access then can not apply labels\n if (!access.isModerator && isLabelEvent) {\n throw new AuthRequiredError('Must be a full moderator to label content')\n }\n\n if (isLabelEvent) {\n validateLabels([\n ...(event.createLabelVals ?? []),\n ...(event.negateLabelVals ?? []),\n ])\n }\n\n const isTakedownOrReverseTakedownEvent =\n isTakedownEvent || isReverseTakedownEvent\n if (isTakedownOrReverseTakedownEvent || isLabelEvent) {\n const status = await moderationService.getStatus(subject)\n\n if (status?.takendown && isTakedownEvent) {\n throw new InvalidRequestError(`Subject is already taken down`)\n }\n\n if (!status?.takendown && isReverseTakedownEvent) {\n throw new InvalidRequestError(`Subject is not taken down`)\n }\n\n if (status?.tags?.length) {\n const protectedTags = await getProtectedTags(\n settingService,\n ctx.cfg.service.did,\n )\n\n if (protectedTags) {\n assertProtectedTagAction({\n protectedTags,\n subjectTags: status.tags,\n actionAuthor: createdBy,\n isAdmin: auth.credentials.isAdmin,\n isModerator: auth.credentials.isModerator,\n isTriage: auth.credentials.isTriage,\n })\n }\n }\n\n if (status?.takendown && isReverseTakedownEvent && subject.isRecord()) {\n // due to the way blob status is modeled, we should reverse takedown on all\n // blobs for the record being restored, which aren't taken down on another record.\n subject.blobCids = status.blobCids ?? []\n }\n }\n\n if (isModEventEmail(event) && event.content) {\n // sending email prior to logging the event to avoid a long transaction below\n if (!subject.isRepo()) {\n throw new InvalidRequestError('Email can only be sent to a repo subject')\n }\n const { content, subjectLine } = event\n // on error, don't fail the whole event. instead, log the event data with isDelivered false\n try {\n await retryHttp(() =>\n ctx.modService(db).sendEmail({\n subject: subjectLine,\n content,\n recipientDid: subject.did,\n }),\n )\n event.isDelivered = true\n } catch (err) {\n event.isDelivered = false\n httpLogger.error({ err, event }, 'failed to send mod event email')\n }\n }\n\n if (isModEventDivert(event) && subject.isRecord()) {\n if (!ctx.blobDiverter) {\n throw new InvalidRequestError(\n 'BlobDiverter not configured for this service',\n )\n }\n await ctx.blobDiverter.uploadBlobOnService(subject.info())\n }\n\n if (\n (isModEventMuteReporter(event) || isModEventUnmuteReporter(event)) &&\n !subject.isRepo()\n ) {\n throw new InvalidRequestError('Subject must be a repo when muting reporter')\n }\n\n if (isModEventTag(event)) {\n await assertTagAuth(settingService, ctx.cfg.service.did, event, auth)\n }\n\n if (isModEventReport(event)) {\n await ctx.moderationServiceProfile().validateReasonType(event.reportType)\n }\n\n const moderationEvent = await db.transaction(async (dbTxn) => {\n const moderationTxn = ctx.modService(dbTxn)\n\n if (externalId) {\n const existingEvent = await moderationTxn.getEventByExternalId(\n getEventType(event.$type),\n externalId,\n subject,\n )\n\n if (existingEvent) {\n throw new InvalidRequestError(\n `An event with the same external ID already exists for the subject.`,\n 'DuplicateExternalId',\n )\n }\n }\n\n // Validate reportAction if provided (actual processing happens after event is logged)\n if (input.body.reportAction) {\n // Validate that at least one targeting criteria is provided\n const { reportAction } = input.body\n if (\n !reportAction.ids?.length &&\n !reportAction.types?.length &&\n !reportAction.all\n ) {\n throw new InvalidRequestError(\n 'reportAction must specify ids, types, or all',\n )\n }\n }\n\n const result = await moderationTxn.logEvent({\n event,\n subject,\n createdBy,\n modTool: input.body.modTool,\n externalId,\n })\n\n // Update reports if reportAction was provided\n if (input.body.reportAction) {\n const subjectUri = subject.isRecord() ? subject.uri : null\n try {\n await processReportAction({\n db: dbTxn,\n reportAction: input.body.reportAction,\n subjectDid: subject.did,\n subjectUri,\n eventId: result.event.id,\n eventType: event.$type,\n createdBy,\n })\n } catch (err) {\n throw new InvalidRequestError(\n err instanceof Error\n ? err.message\n : 'Failed to process report action',\n )\n }\n }\n\n const tagService = new TagService(\n subject,\n result.subjectStatus,\n ctx.cfg.service.did,\n moderationTxn,\n )\n\n const initialTags = isModEventReport(event)\n ? [getTagForReport(event.reportType)]\n : undefined\n await tagService.evaluateForSubject(initialTags)\n\n if (subject.isRepo()) {\n if (isTakedownEvent) {\n const isSuspend = !!result.event.durationInHours\n await moderationTxn.takedownRepo(\n subject,\n result.event.id,\n new Set(\n result.event.meta?.targetServices\n ? `${result.event.meta.targetServices}`.split(',')\n : undefined,\n ),\n isSuspend,\n )\n } else if (isReverseTakedownEvent) {\n await moderationTxn.reverseTakedownRepo(subject)\n }\n }\n\n if (subject.isRecord()) {\n if (isTakedownEvent) {\n await moderationTxn.takedownRecord(\n subject,\n result.event.id,\n new Set(\n result.event.meta?.targetServices\n ? `${result.event.meta.targetServices}`.split(',')\n : undefined,\n ),\n )\n } else if (isReverseTakedownEvent) {\n await moderationTxn.reverseTakedownRecord(subject)\n }\n }\n\n if (\n (isTakedownEvent || isAcknowledgeEvent) &&\n result.event.meta?.acknowledgeAccountSubjects\n ) {\n await moderationTxn.resolveSubjectsForAccount(\n subject.did,\n createdBy,\n result.event,\n )\n }\n\n if (isLabelEvent) {\n await moderationTxn.formatAndCreateLabels(\n result.event.subjectUri ?? result.event.subjectDid,\n result.event.subjectCid,\n {\n create: result.event.createLabelVals?.length\n ? result.event.createLabelVals.split(' ')\n : undefined,\n negate: result.event.negateLabelVals?.length\n ? result.event.negateLabelVals.split(' ')\n : undefined,\n },\n result.event.durationInHours ?? undefined,\n )\n }\n\n return result.event\n })\n\n return moderationService.views.formatEvent(moderationEvent)\n}\n\nexport default function (server: Server, ctx: AppContext) {\n server.tools.ozone.moderation.emitEvent({\n auth: ctx.authVerifier.modOrAdminToken,\n handler: async ({ input, auth }) => {\n try {\n const moderationEvent = await handleModerationEvent({\n input,\n auth,\n ctx,\n })\n\n // On divert events, we need to automatically take down the blobs\n if (isModEventDivert(input.body.event)) {\n await handleModerationEvent({\n auth,\n ctx,\n input: {\n ...input,\n body: {\n ...input.body,\n event: {\n ...input.body.event,\n $type: 'tools.ozone.moderation.defs#modEventTakedown',\n comment:\n '[DIVERT_SIDE_EFFECT]: Automatically taking down after divert event',\n },\n modTool: input.body.modTool,\n },\n },\n })\n }\n\n return {\n encoding: 'application/json',\n body: moderationEvent,\n }\n } catch (err) {\n httpLogger.error(\n { err, body: input.body },\n 'failed to emit moderation event',\n )\n throw err\n }\n },\n })\n}\n\nconst assertTagAuth = async (\n settingService: SettingService,\n serviceDid: string,\n event: ModEventTag,\n auth: ModeratorOutput | AdminTokenOutput,\n) => {\n // admins can add/remove any tag\n if (auth.credentials.isAdmin) return\n\n const protectedTags = await getProtectedTags(settingService, serviceDid)\n\n if (!protectedTags) {\n return\n }\n\n for (const tag of Object.keys(protectedTags)) {\n if (event.add.includes(tag) || event.remove.includes(tag)) {\n // if specific moderators are configured to manage this tag but the current user\n // is not one of them, then throw an error\n const configuredModerators = protectedTags[tag]?.['moderators']\n if (\n configuredModerators &&\n !configuredModerators.includes(auth.credentials.iss)\n ) {\n throw new InvalidRequestError(`Not allowed to manage tag: ${tag}`)\n }\n\n const configuredRoles = protectedTags[tag]?.['roles']\n if (configuredRoles) {\n // admins can already do everything so we only check for moderator and triage role config\n if (\n auth.credentials.isModerator &&\n !configuredRoles.includes('tools.ozone.team.defs#roleModerator')\n ) {\n throw new InvalidRequestError(\n `Can not manage tag ${tag} with moderator role`,\n )\n } else if (\n auth.credentials.isTriage &&\n !configuredRoles.includes('tools.ozone.team.defs#roleTriage')\n ) {\n throw new InvalidRequestError(\n `Can not manage tag ${tag} with triage role`,\n )\n }\n }\n }\n }\n}\n\nconst validateLabels = (labels: string[]) => {\n for (const label of labels) {\n for (const char of badChars) {\n if (label.includes(char)) {\n throw new InvalidRequestError(`Invalid label: ${label}`)\n }\n }\n }\n}\n\nconst badChars = [' ', ',', ';', `'`, `\"`]\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assignModerator.d.ts","sourceRoot":"","sources":["../../../src/api/queue/assignModerator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAGtC,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAyBvD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const xrpc_server_1 = require("@atproto/xrpc-server");
|
|
5
|
+
const util_1 = require("../util");
|
|
6
|
+
function default_1(server, ctx) {
|
|
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 = (0, util_1.getAuthDid)(auth, ctx.cfg.service.did);
|
|
12
|
+
// RBAC
|
|
13
|
+
if (!auth.credentials.isModerator) {
|
|
14
|
+
throw new xrpc_server_1.ForbiddenError('Unauthorized');
|
|
15
|
+
}
|
|
16
|
+
// RuBAC
|
|
17
|
+
if (did !== authDid && !auth.credentials.isAdmin) {
|
|
18
|
+
throw new xrpc_server_1.ForbiddenError('Unauthorized');
|
|
19
|
+
}
|
|
20
|
+
const result = await ctx.assignmentService.assignQueue({ did, queueId });
|
|
21
|
+
return {
|
|
22
|
+
encoding: 'application/json',
|
|
23
|
+
body: result,
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=assignModerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assignModerator.js","sourceRoot":"","sources":["../../../src/api/queue/assignModerator.ts"],"names":[],"mappings":";;AAKA,4BAyBC;AA9BD,sDAAqD;AAGrD,kCAAoC;AAEpC,mBAAyB,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC;QACvC,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,eAAe;QACtC,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE;YACjC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,IAAI,CAAA;YACnC,MAAM,OAAO,GAAG,IAAA,iBAAU,EAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;YAErD,OAAO;YACP,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;gBAClC,MAAM,IAAI,4BAAc,CAAC,cAAc,CAAC,CAAA;YAC1C,CAAC;YAED,QAAQ;YACR,IAAI,GAAG,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;gBACjD,MAAM,IAAI,4BAAc,CAAC,cAAc,CAAC,CAAA;YAC1C,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA;YAExE,OAAO;gBACL,QAAQ,EAAE,kBAAkB;gBAC5B,IAAI,EAAE,MAAM;aACb,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { ForbiddenError } from '@atproto/xrpc-server'\nimport { AppContext } from '../../context'\nimport { Server } from '../../lexicon'\nimport { getAuthDid } from '../util'\n\nexport default function (server: Server, ctx: AppContext) {\n server.tools.ozone.queue.assignModerator({\n auth: ctx.authVerifier.modOrAdminToken,\n handler: async ({ input, auth }) => {\n const { queueId, did } = input.body\n const authDid = getAuthDid(auth, ctx.cfg.service.did)\n\n // RBAC\n if (!auth.credentials.isModerator) {\n throw new ForbiddenError('Unauthorized')\n }\n\n // RuBAC\n if (did !== authDid && !auth.credentials.isAdmin) {\n throw new ForbiddenError('Unauthorized')\n }\n\n const result = await ctx.assignmentService.assignQueue({ did, queueId })\n\n return {\n encoding: 'application/json',\n body: result,\n }\n },\n })\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createQueue.d.ts","sourceRoot":"","sources":["../../../src/api/queue/createQueue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAItC,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAuDvD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const xrpc_server_1 = require("@atproto/xrpc-server");
|
|
5
|
+
const VALID_SUBJECT_TYPES = ['account', 'record', 'message'];
|
|
6
|
+
function default_1(server, ctx) {
|
|
7
|
+
server.tools.ozone.queue.createQueue({
|
|
8
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
9
|
+
handler: async ({ input, auth }) => {
|
|
10
|
+
const access = auth.credentials;
|
|
11
|
+
if (!access.isModerator) {
|
|
12
|
+
throw new xrpc_server_1.AuthRequiredError('Must be a moderator to create a queue');
|
|
13
|
+
}
|
|
14
|
+
const { name, subjectTypes, collection, reportTypes, description } = input.body;
|
|
15
|
+
const createdBy = access.type === 'admin_token' ? 'admin_token' : access.iss;
|
|
16
|
+
const invalidTypes = subjectTypes.filter((t) => !VALID_SUBJECT_TYPES.includes(t));
|
|
17
|
+
if (invalidTypes.length > 0) {
|
|
18
|
+
throw new xrpc_server_1.InvalidRequestError(`Invalid subject types: ${invalidTypes.join(', ')}. Allowed values: ${VALID_SUBJECT_TYPES.join(', ')}`, 'InvalidSubjectType');
|
|
19
|
+
}
|
|
20
|
+
if (collection && !subjectTypes.includes('record')) {
|
|
21
|
+
throw new xrpc_server_1.InvalidRequestError('collection can only be specified when subjectTypes includes "record"', 'InvalidCollection');
|
|
22
|
+
}
|
|
23
|
+
const queueService = ctx.queueService(ctx.db);
|
|
24
|
+
await queueService.checkConflict({
|
|
25
|
+
subjectTypes,
|
|
26
|
+
collection,
|
|
27
|
+
reportTypes,
|
|
28
|
+
});
|
|
29
|
+
const queue = await queueService.create({
|
|
30
|
+
name,
|
|
31
|
+
subjectTypes,
|
|
32
|
+
collection,
|
|
33
|
+
reportTypes,
|
|
34
|
+
description,
|
|
35
|
+
createdBy,
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
encoding: 'application/json',
|
|
39
|
+
body: { queue: queueService.view(queue) },
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=createQueue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createQueue.js","sourceRoot":"","sources":["../../../src/api/queue/createQueue.ts"],"names":[],"mappings":";;AAMA,4BAuDC;AA7DD,sDAA6E;AAI7E,MAAM,mBAAmB,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAA;AAE5D,mBAAyB,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC;QACnC,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,eAAe;QACtC,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE;YACjC,MAAM,MAAM,GAAG,IAAI,CA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AkB;gBAC5B,IAAI,EAAE,EAAE,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;aAC1C,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { AuthRequiredError, InvalidRequestError } from '@atproto/xrpc-server'\nimport { AppContext } from '../../context'\nimport { Server } from '../../lexicon'\n\nconst VALID_SUBJECT_TYPES = ['account', 'record', 'message']\n\nexport default function (server: Server, ctx: AppContext) {\n server.tools.ozone.queue.createQueue({\n auth: ctx.authVerifier.modOrAdminToken,\n handler: async ({ input, auth }) => {\n const access = auth.credentials\n\n if (!access.isModerator) {\n throw new AuthRequiredError('Must be a moderator to create a queue')\n }\n\n const { name, subjectTypes, collection, reportTypes, description } =\n input.body\n const createdBy =\n access.type === 'admin_token' ? 'admin_token' : access.iss\n\n const invalidTypes = subjectTypes.filter(\n (t) => !VALID_SUBJECT_TYPES.includes(t),\n )\n if (invalidTypes.length > 0) {\n throw new InvalidRequestError(\n `Invalid subject types: ${invalidTypes.join(', ')}. Allowed values: ${VALID_SUBJECT_TYPES.join(', ')}`,\n 'InvalidSubjectType',\n )\n }\n\n if (collection && !subjectTypes.includes('record')) {\n throw new InvalidRequestError(\n 'collection can only be specified when subjectTypes includes \"record\"',\n 'InvalidCollection',\n )\n }\n\n const queueService = ctx.queueService(ctx.db)\n\n await queueService.checkConflict({\n subjectTypes,\n collection,\n reportTypes,\n })\n\n const queue = await queueService.create({\n name,\n subjectTypes,\n collection,\n reportTypes,\n description,\n createdBy,\n })\n\n return {\n encoding: 'application/json',\n body: { queue: queueService.view(queue) },\n }\n },\n })\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteQueue.d.ts","sourceRoot":"","sources":["../../../src/api/queue/deleteQueue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtC,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAmDvD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const xrpc_server_1 = require("@atproto/xrpc-server");
|
|
5
|
+
function default_1(server, ctx) {
|
|
6
|
+
server.tools.ozone.queue.deleteQueue({
|
|
7
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
8
|
+
handler: async ({ input, auth }) => {
|
|
9
|
+
const access = auth.credentials;
|
|
10
|
+
if (!access.isModerator) {
|
|
11
|
+
throw new xrpc_server_1.AuthRequiredError('Must be a moderator to delete a queue');
|
|
12
|
+
}
|
|
13
|
+
const { queueId, migrateToQueueId } = input.body;
|
|
14
|
+
const queueService = ctx.queueService(ctx.db);
|
|
15
|
+
const existing = await queueService.getById(queueId);
|
|
16
|
+
if (!existing) {
|
|
17
|
+
throw new xrpc_server_1.InvalidRequestError(`Queue with id ${queueId} does not exist`, 'QueueNotFound');
|
|
18
|
+
}
|
|
19
|
+
if (migrateToQueueId !== undefined) {
|
|
20
|
+
const targetQueue = await queueService.getById(migrateToQueueId);
|
|
21
|
+
if (!targetQueue) {
|
|
22
|
+
throw new xrpc_server_1.InvalidRequestError(`Target queue with id ${migrateToQueueId} does not exist`, 'QueueNotFound');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// Migrate non-closed reports before soft-deleting the queue.
|
|
26
|
+
// Closed reports are left assigned to the deleted queue — their history is preserved.
|
|
27
|
+
// Non-closed reports go to migrateToQueueId if specified, otherwise to -1 (unmatched).
|
|
28
|
+
const reportsMigrated = await queueService.migrateReports(queueId, migrateToQueueId);
|
|
29
|
+
await queueService.delete(queueId);
|
|
30
|
+
return {
|
|
31
|
+
encoding: 'application/json',
|
|
32
|
+
body: {
|
|
33
|
+
deleted: true,
|
|
34
|
+
reportsMigrated,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=deleteQueue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteQueue.js","sourceRoot":"","sources":["../../../src/api/queue/deleteQueue.ts"],"names":[],"mappings":";;AAIA,4BAmDC;AAvDD,sDAA6E;AAI7E,mBAAyB,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC;QACnC,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,eAAe;QACtC,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE;YACjC,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAA;YAE/B,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;gBACxB,MAAM,IAAI,+BAAiB,CAAC,uCAAuC,CAAC,CAAA;YACtE,CAAC;YAED,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC,IAAI,CAAA;YAEhD,MAAM,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YAE7C,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;YACpD,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,MAAM,IAAI,iCAAmB,CAC3B,iBAAiB,OAAO,iBAAiB,EACzC,eAAe,CAChB,CAAA;YACH,CAAC;YAED,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBACnC,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;gBAChE,IAAI,CAAC,WAAW,EAAE,CAAC;oBACjB,MAAM,IAAI,iCAAmB,CAC3B,wBAAwB,gBAAgB,iBAAiB,EACzD,eAAe,CAChB,CAAA;gBACH,CAAC;YACH,CAAC;YAED,6DAA6D;YAC7D,sFAAsF;YACtF,uFAAuF;YACvF,MAAM,eAAe,GAAG,MAAM,YAAY,CAAC,cAAc,CACvD,OAAO,EACP,gBAAgB,CACjB,CAAA;YAED,MAAM,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;YAElC,OAAO;gBACL,QAAQ,EAAE,kBAAkB;gBAC5B,IAAI,EAAE;oBACJ,OAAO,EAAE,IAAI;oBACb,eAAe;iBAChB;aACF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { AuthRequiredError, InvalidRequestError } from '@atproto/xrpc-server'\nimport { AppContext } from '../../context'\nimport { Server } from '../../lexicon'\n\nexport default function (server: Server, ctx: AppContext) {\n server.tools.ozone.queue.deleteQueue({\n auth: ctx.authVerifier.modOrAdminToken,\n handler: async ({ input, auth }) => {\n const access = auth.credentials\n\n if (!access.isModerator) {\n throw new AuthRequiredError('Must be a moderator to delete a queue')\n }\n\n const { queueId, migrateToQueueId } = input.body\n\n const queueService = ctx.queueService(ctx.db)\n\n const existing = await queueService.getById(queueId)\n if (!existing) {\n throw new InvalidRequestError(\n `Queue with id ${queueId} does not exist`,\n 'QueueNotFound',\n )\n }\n\n if (migrateToQueueId !== undefined) {\n const targetQueue = await queueService.getById(migrateToQueueId)\n if (!targetQueue) {\n throw new InvalidRequestError(\n `Target queue with id ${migrateToQueueId} does not exist`,\n 'QueueNotFound',\n )\n }\n }\n\n // Migrate non-closed reports before soft-deleting the queue.\n // Closed reports are left assigned to the deleted queue — their history is preserved.\n // Non-closed reports go to migrateToQueueId if specified, otherwise to -1 (unmatched).\n const reportsMigrated = await queueService.migrateReports(\n queueId,\n migrateToQueueId,\n )\n\n await queueService.delete(queueId)\n\n return {\n encoding: 'application/json',\n body: {\n deleted: true,\n reportsMigrated,\n },\n }\n },\n })\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAssignments.d.ts","sourceRoot":"","sources":["../../../src/api/queue/getAssignments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtC,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAevD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
function default_1(server, ctx) {
|
|
5
|
+
server.tools.ozone.queue.getAssignments({
|
|
6
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
7
|
+
handler: async ({ params }) => {
|
|
8
|
+
const result = await ctx.assignmentService.getQueueAssignments(params);
|
|
9
|
+
return {
|
|
10
|
+
encoding: 'application/json',
|
|
11
|
+
body: {
|
|
12
|
+
assignments: result.assignments,
|
|
13
|
+
cursor: result.cursor,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=getAssignments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAssignments.js","sourceRoot":"","sources":["../../../src/api/queue/getAssignments.ts"],"names":[],"mappings":";;AAGA,4BAeC;AAfD,mBAAyB,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC;QACtC,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,eAAe;QACtC,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YAC5B,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAA;YAEtE,OAAO;gBACL,QAAQ,EAAE,kBAAkB;gBAC5B,IAAI,EAAE;oBACJ,WAAW,EAAE,MAAM,CAAC,WAAW;oBAC/B,MAAM,EAAE,MAAM,CAAC,MAAM;iBACtB;aACF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { AppContext } from '../../context'\nimport { Server } from '../../lexicon'\n\nexport default function (server: Server, ctx: AppContext) {\n server.tools.ozone.queue.getAssignments({\n auth: ctx.authVerifier.modOrAdminToken,\n handler: async ({ params }) => {\n const result = await ctx.assignmentService.getQueueAssignments(params)\n\n return {\n encoding: 'application/json',\n body: {\n assignments: result.assignments,\n cursor: result.cursor,\n },\n }\n },\n })\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listQueues.d.ts","sourceRoot":"","sources":["../../../src/api/queue/listQueues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtC,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAmCvD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
function default_1(server, ctx) {
|
|
5
|
+
server.tools.ozone.queue.listQueues({
|
|
6
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
7
|
+
handler: async ({ params }) => {
|
|
8
|
+
const { limit = 50, cursor, enabled, subjectType, collection, reportTypes, } = params;
|
|
9
|
+
const queueService = ctx.queueService(ctx.db);
|
|
10
|
+
const result = await queueService.list({
|
|
11
|
+
limit,
|
|
12
|
+
cursor,
|
|
13
|
+
enabled,
|
|
14
|
+
subjectType,
|
|
15
|
+
collection,
|
|
16
|
+
reportTypes,
|
|
17
|
+
});
|
|
18
|
+
const queues = await queueService.viewsWithStats(result.queues);
|
|
19
|
+
return {
|
|
20
|
+
encoding: 'application/json',
|
|
21
|
+
body: {
|
|
22
|
+
queues,
|
|
23
|
+
cursor: result.cursor,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=listQueues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listQueues.js","sourceRoot":"","sources":["../../../src/api/queue/listQueues.ts"],"names":[],"mappings":";;AAGA,4BAmCC;AAnCD,mBAAyB,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC;QAClC,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,eAAe;QACtC,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YAC5B,MAAM,EACJ,KAAK,GAAG,EAAE,EACV,MAAM,EACN,OAAO,EACP,WAAW,EACX,UAAU,EACV,WAAW,GACZ,GAAG,MAAM,CAAA;YAEV,MAAM,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YAE7C,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC;gBACrC,KAAK;gBACL,MAAM;gBACN,OAAO;gBACP,WAAW;gBACX,UAAU;gBACV,WAAW;aACZ,CAAC,CAAA;YAEF,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YAE/D,OAAO;gBACL,QAAQ,EAAE,kBAAkB;gBAC5B,IAAI,EAAE;oBACJ,MAAM;oBACN,MAAM,EAAE,MAAM,CAAC,MAAM;iBACtB;aACF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { AppContext } from '../../context'\nimport { Server } from '../../lexicon'\n\nexport default function (server: Server, ctx: AppContext) {\n server.tools.ozone.queue.listQueues({\n auth: ctx.authVerifier.modOrAdminToken,\n handler: async ({ params }) => {\n const {\n limit = 50,\n cursor,\n enabled,\n subjectType,\n collection,\n reportTypes,\n } = params\n\n const queueService = ctx.queueService(ctx.db)\n\n const result = await queueService.list({\n limit,\n cursor,\n enabled,\n subjectType,\n collection,\n reportTypes,\n })\n\n const queues = await queueService.viewsWithStats(result.queues)\n\n return {\n encoding: 'application/json',\n body: {\n queues,\n cursor: result.cursor,\n },\n }\n },\n })\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routeReports.d.ts","sourceRoot":"","sources":["../../../src/api/queue/routeReports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAItC,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAqCvD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const xrpc_server_1 = require("@atproto/xrpc-server");
|
|
5
|
+
const MAX_REPORTS = 5000;
|
|
6
|
+
function default_1(server, ctx) {
|
|
7
|
+
server.tools.ozone.queue.routeReports({
|
|
8
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
9
|
+
handler: async ({ input, auth }) => {
|
|
10
|
+
const access = auth.credentials;
|
|
11
|
+
const { startReportId, endReportId } = input.body;
|
|
12
|
+
if (!access.isModerator) {
|
|
13
|
+
throw new xrpc_server_1.AuthRequiredError('Must be an admin to re-route reports');
|
|
14
|
+
}
|
|
15
|
+
if (startReportId > endReportId) {
|
|
16
|
+
throw new xrpc_server_1.InvalidRequestError('startReportId must be less than or equal to endReportId');
|
|
17
|
+
}
|
|
18
|
+
if (endReportId - startReportId + 1 > MAX_REPORTS) {
|
|
19
|
+
throw new xrpc_server_1.InvalidRequestError(`Cannot route more than ${MAX_REPORTS} reports at a time`, 'OutOfRange');
|
|
20
|
+
}
|
|
21
|
+
const queueService = ctx.queueService(ctx.db);
|
|
22
|
+
const { assigned, unmatched } = await queueService.assignReportBatch({ start: startReportId, end: endReportId, limit: MAX_REPORTS }, { includeUnmatched: true });
|
|
23
|
+
return {
|
|
24
|
+
encoding: 'application/json',
|
|
25
|
+
body: {
|
|
26
|
+
assigned,
|
|
27
|
+
unmatched,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=routeReports.js.map
|