-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Evented architecture for moderation system (#1617)
* 🚧 WIP with proposed lexicons for event based mod architecture * 🚧 Remove unnecessary moderation action lexicon * 🚧 Working on event based actions * ✨ Add escalated subject status * 🐛 Alright, fixed the error in lexicon * 🚧 Working through reversal * ✨ Cleanup build errors * ✨ Add subject status endpoint * ✨ Add handler * ✨ get reports from mod actions table * :rightwards_twisted_arrows: Merge with upstream * 🚧 Builds but test network doesnt start * ✨ Tests passing on event based status change * ✨ Rename index * ♻️ Rename takeModerationAction->emitModerationEvent * ✨ Implement label reversal * ✅ Auto-revert test working * ♻️ ✅ Refactored to event types and tests are passing * ✨ Add takedown event sequence validation * ✨ Adds support for blobCid status * 🧹 Cleanup unnecessary method: * ✨ Hydrate handles with status and events * ✨ Re-implement auto reversal * ✨ Add takendown and mute filters * ✨ Allow filtering events by type * ✨ Allow filtering events by creator did * ✨ Add subjectStatus to record and repoview * ✨ Add persistent note feature * ✨ Log send email event * 🐛 Fix logging send email event * ✨ Better type * ✨ Adjust migration to create separate moderation_event table * 🧹 Cleanup types * ✅ Adjust tests with mod event emitter * ✨ Fix more tests around takedowns * ✅ Get test suite to pass * ✅ Get test suite to pass for pds * ✅ Get test suite to pass for pds * ✅ Update snapshot for feedgen * ✅ Why are more snapshots updating? * ♻️ Rename getModerationEvents -> queryModerationEvents * ♻️ Rename getModerationStatuses -> queryModerationStatuses * ♻️ Rename persistNote->sticky * 🐛 Rename subject * ♻️ Cleanup expiresAt for scheduled actions * ✨ Add more tests, allow fetching mod history for all content by a user * ✅ Fix repo and record tests * ✨ Migrate reports and actions to events * 🐛 Fix escalated status overwrite * ✨ Implement direct sql query to create events from actions and reports * 🚧 Adding keyset pagination for subject statuses * ✨ Add migration for lastReportedAt * ✨ Migrate blob cids * ✨ Fix pagination on mod subject list endpoint * 🐛 Fix blob actions * ✅ All tests passing on bsky package * ✅ Bring back snapshots * ✅ Skipping timeline test temporarily * ✅ Skipping some more tests to isolate failing ones * ✅ Bring back list-feed test * ✅ Bring back timeline test * ✅ Fix label action in seeding * ✅ Enable timeline proxied test * ✅ Enable search actor proxied test * ✅ Enable feedgen tests * ✅ Fix test for admin/get-record * ✨ Move note to comment for subject status * ✨ Accept comments in mute event * ✨ Remap flag event to ack event * 🐛 Add legacyRef in report union selection * @atproto/api 0.6.24-next.0 * @atproto/api 0.6.24-next.1 * ✨ Adjust migration export and add index for blobCids column * ✨ Maintin action ids when migrating * ✨ Paginate events using createdAt timestamp * ✅ Update snapshot for pds test with events cursor update * ✅ Use only events for snapshot testing * ✅ Use only events for snapshot in the remaining test * relative paths to lexicons for build * fix bsky periodic event reversal in service entrypoint * ✨ Allow comments in takedown and label * ✨ Only import reports on consecutive run of the migration script * ✨ Adjust moderation property of blob entries * determine latest reports to migrate * ✨ Process new reports for subject status * ✨ Process unresolved reports on first migration run * fix transaction error, process just unresolved reports, make reported-at updates safe for reruns * tidy --------- Co-authored-by: Devin Ivy <[email protected]>
- Loading branch information
Showing
119 changed files
with
6,855 additions
and
7,487 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"lexicon": 1, | ||
"id": "com.atproto.admin.queryModerationEvents", | ||
"defs": { | ||
"main": { | ||
"type": "query", | ||
"description": "List moderation events related to a subject.", | ||
"parameters": { | ||
"type": "params", | ||
"properties": { | ||
"types": { | ||
"type": "array", | ||
"items": { "type": "string" }, | ||
"description": "The types of events (fully qualified string in the format of com.atproto.admin#modEvent<name>) to filter by. If not specified, all events are returned." | ||
}, | ||
"createdBy": { | ||
"type": "string", | ||
"format": "did" | ||
}, | ||
"sortDirection": { | ||
"type": "string", | ||
"default": "desc", | ||
"enum": ["asc", "desc"], | ||
"description": "Sort direction for the events. Defaults to descending order of created at timestamp." | ||
}, | ||
"subject": { "type": "string", "format": "uri" }, | ||
"includeAllUserRecords": { | ||
"type": "boolean", | ||
"default": false, | ||
"description": "If true, events on all record types (posts, lists, profile etc.) owned by the did are returned" | ||
}, | ||
"limit": { | ||
"type": "integer", | ||
"minimum": 1, | ||
"maximum": 100, | ||
"default": 50 | ||
}, | ||
"cursor": { "type": "string" } | ||
} | ||
}, | ||
"output": { | ||
"encoding": "application/json", | ||
"schema": { | ||
"type": "object", | ||
"required": ["events"], | ||
"properties": { | ||
"cursor": { "type": "string" }, | ||
"events": { | ||
"type": "array", | ||
"items": { | ||
"type": "ref", | ||
"ref": "com.atproto.admin.defs#modEventView" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{ | ||
"lexicon": 1, | ||
"id": "com.atproto.admin.queryModerationStatuses", | ||
"defs": { | ||
"main": { | ||
"type": "query", | ||
"description": "View moderation statuses of subjects (record or repo).", | ||
"parameters": { | ||
"type": "params", | ||
"properties": { | ||
"subject": { "type": "string", "format": "uri" }, | ||
"comment": { | ||
"type": "string", | ||
"description": "Search subjects by keyword from comments" | ||
}, | ||
"reportedAfter": { | ||
"type": "string", | ||
"format": "datetime", | ||
"description": "Search subjects reported after a given timestamp" | ||
}, | ||
"reportedBefore": { | ||
"type": "string", | ||
"format": "datetime", | ||
"description": "Search subjects reported before a given timestamp" | ||
}, | ||
"reviewedAfter": { | ||
"type": "string", | ||
"format": "datetime", | ||
"description": "Search subjects reviewed after a given timestamp" | ||
}, | ||
"reviewedBefore": { | ||
"type": "string", | ||
"format": "datetime", | ||
"description": "Search subjects reviewed before a given timestamp" | ||
}, | ||
"includeMuted": { | ||
"type": "boolean", | ||
"description": "By default, we don't include muted subjects in the results. Set this to true to include them." | ||
}, | ||
"reviewState": { | ||
"type": "string", | ||
"description": "Specify when fetching subjects in a certain state" | ||
}, | ||
"ignoreSubjects": { | ||
"type": "array", | ||
"items": { "type": "string", "format": "uri" } | ||
}, | ||
"lastReviewedBy": { | ||
"type": "string", | ||
"format": "did", | ||
"description": "Get all subject statuses that were reviewed by a specific moderator" | ||
}, | ||
"sortField": { | ||
"type": "string", | ||
"default": "lastReportedAt", | ||
"enum": ["lastReviewedAt", "lastReportedAt"] | ||
}, | ||
"sortDirection": { | ||
"type": "string", | ||
"default": "desc", | ||
"enum": ["asc", "desc"] | ||
}, | ||
"takendown": { | ||
"type": "boolean", | ||
"description": "Get subjects that were taken down" | ||
}, | ||
"limit": { | ||
"type": "integer", | ||
"minimum": 1, | ||
"maximum": 100, | ||
"default": 50 | ||
}, | ||
"cursor": { "type": "string" } | ||
} | ||
}, | ||
"output": { | ||
"encoding": "application/json", | ||
"schema": { | ||
"type": "object", | ||
"required": ["subjectStatuses"], | ||
"properties": { | ||
"cursor": { "type": "string" }, | ||
"subjectStatuses": { | ||
"type": "array", | ||
"items": { | ||
"type": "ref", | ||
"ref": "com.atproto.admin.defs#subjectStatusView" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.