Skip to content

Commit

Permalink
Feature: admin moderation views (bluesky-social#472)
Browse files Browse the repository at this point in the history
* Model mod actions for actor takedowns

* Add administration lex schemas for moderation actions

* Initial implementation of takedown mod action and reversal

* Refactor admin actions into a service

* Check for account takedown when creating new session or refreshing session

* Sweep usage of getUser() and getUserByEmail() for takedowns

* Begin sweep for account takedowns

* Tidy takedown checks

* Handle post author takedowns

* Fix tests and migrations for mod takedown

* Fix xrpc-server delayed read of blob payloads

* Test takedown mod action, misc fixes

* Remodel lex schemas for admin moderation actions

* Remove delcaration cid from actor takedowns, lex schema tidy

* Add notes

* Move moderation methods to com.atproto, based around repo rather than actor

* Moderation reports of repos and records

* Implement moderation report resolution method

* Tidy

* Place moderation-init migration after mute-init

* Allow services to reference each other

* Model record takedowns in db

* Lex schemas for record takedowns

* Service/methods for record takedowns, fix report view subject

* Apply record takedown to posts in feeds

* Test record takedown effects, fix reversal

* Support server moderation flag and acknowledge actions, fix action/report resolution for records

* Track repo takedowns on repo_root rather than did_handle

* Move repo/record reporting under com.atproto.report

* Colocate all moderation functionality into moderation service, combine from admin and repo services

* Tidy

* Tidy

* Unify mod report and action methods with new repo/record ref schemas

* Schemas for admin moderation views

* Tidy/codegen

* Fix test snapshot

* Break pds admin methods into separate files

* Implment admin repo search method

* Reorganize existing moderation views into the ModerationViews

* Lex schemas for admin get repo/record, implement get repo

* Implement admin get record view

* Tidy/codegen

* Tidy, fix snapshot

* Tidy, swap filenames

* Implement admin get moderation action view

* Implement admin get moderation report view

* Implement and test admin views for mod actions and reports

* Dry-up some admin and moderation-related seeds in the tests

* Fix xrpc fetch usage for newly required duplex option

* Admin view of repo and record details (bluesky-social#463)

* Reorganize existing moderation views into the ModerationViews

* Lex schemas for admin get repo/record, implement get repo

* Implement admin get record view

* Tidy/codegen

* Tidy, fix snapshot
  • Loading branch information
devinivy authored Jan 18, 2023
1 parent 87d27c0 commit 13dd58b
Show file tree
Hide file tree
Showing 90 changed files with 6,390 additions and 319 deletions.
21 changes: 21 additions & 0 deletions lexicons/com/atproto/admin/getModerationAction.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"lexicon": 1,
"id": "com.atproto.admin.getModerationAction",
"defs": {
"main": {
"type": "query",
"description": "View details about a moderation action.",
"parameters": {
"type": "params",
"required": ["id"],
"properties": {
"id": {"type": "number"}
}
},
"output": {
"encoding": "application/json",
"schema": {"type": "ref", "ref": "com.atproto.admin.moderationAction#viewDetail"}
}
}
}
}
29 changes: 29 additions & 0 deletions lexicons/com/atproto/admin/getModerationActions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"lexicon": 1,
"id": "com.atproto.admin.getModerationActions",
"defs": {
"main": {
"type": "query",
"description": "List moderation actions related to a subject.",
"parameters": {
"type": "params",
"properties": {
"subject": {"type": "string"},
"limit": {"type": "integer", "minimum": 1, "maximum": 100, "default": 50},
"before": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["actions"],
"properties": {
"cursor": {"type": "string"},
"actions": {"type": "array", "items": {"type": "ref", "ref": "com.atproto.admin.moderationAction#view"}}
}
}
}
}
}
}
21 changes: 21 additions & 0 deletions lexicons/com/atproto/admin/getModerationReport.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"lexicon": 1,
"id": "com.atproto.admin.getModerationReport",
"defs": {
"main": {
"type": "query",
"description": "View details about a moderation report.",
"parameters": {
"type": "params",
"required": ["id"],
"properties": {
"id": {"type": "number"}
}
},
"output": {
"encoding": "application/json",
"schema": {"type": "ref", "ref": "com.atproto.admin.moderationReport#viewDetail"}
}
}
}
}
30 changes: 30 additions & 0 deletions lexicons/com/atproto/admin/getModerationReports.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"lexicon": 1,
"id": "com.atproto.admin.getModerationReports",
"defs": {
"main": {
"type": "query",
"description": "List moderation reports related to a subject.",
"parameters": {
"type": "params",
"properties": {
"subject": {"type": "string"},
"resolved": {"type": "boolean"},
"limit": {"type": "integer", "minimum": 1, "maximum": 100, "default": 50},
"before": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["reports"],
"properties": {
"cursor": {"type": "string"},
"reports": {"type": "array", "items": {"type": "ref", "ref": "com.atproto.admin.moderationReport#view"}}
}
}
}
}
}
}
22 changes: 22 additions & 0 deletions lexicons/com/atproto/admin/getRecord.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"lexicon": 1,
"id": "com.atproto.admin.getRecord",
"defs": {
"main": {
"type": "query",
"description": "View details about a record.",
"parameters": {
"type": "params",
"required": ["uri"],
"properties": {
"uri": {"type": "string"},
"cid": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
"schema": {"type": "ref", "ref": "com.atproto.admin.record#viewDetail"}
}
}
}
}
21 changes: 21 additions & 0 deletions lexicons/com/atproto/admin/getRepo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"lexicon": 1,
"id": "com.atproto.admin.getRepo",
"defs": {
"main": {
"type": "query",
"description": "View details about a repository.",
"parameters": {
"type": "params",
"required": ["did"],
"properties": {
"did": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
"schema": {"type": "ref", "ref": "com.atproto.admin.repo#viewDetail"}
}
}
}
}
45 changes: 36 additions & 9 deletions lexicons/com/atproto/admin/moderationAction.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
"defs": {
"view": {
"type": "object",
"required": ["id", "action", "subject", "reason", "createdBy", "createdAt", "resolvedReports"],
"required": ["id", "action", "subject", "reason", "createdBy", "createdAt", "resolvedReportIds"],
"properties": {
"id": {"type": "integer"},
"action": {"type": "string", "knownValues": ["com.atproto.admin.moderationAction#takedown"]},
"action": {
"type": "string",
"knownValues": [
"com.atproto.admin.moderationAction#takedown",
"com.atproto.admin.moderationAction#flag",
"com.atproto.admin.moderationAction#acknowledge"
]
},
"subject": {
"type": "union",
"refs": [
Expand All @@ -19,23 +26,43 @@
"createdBy": {"type": "string"},
"createdAt": {"type": "string"},
"reversal": {"type": "ref", "ref": "#reversal"},
"resolvedReports": {"type": "array", "items": {"type" :"ref", "ref": "#resolvedReport"}}
"resolvedReportIds": {"type": "array", "items": {"type": "integer"}}
}
},
"reversal": {
"viewDetail": {
"type": "object",
"required": ["reason", "createdBy", "createdAt"],
"required": ["id", "action", "subject", "reason", "createdBy", "createdAt", "resolvedReports"],
"properties": {
"id": {"type": "integer"},
"action": {
"type": "string",
"knownValues": [
"com.atproto.admin.moderationAction#takedown",
"com.atproto.admin.moderationAction#flag",
"com.atproto.admin.moderationAction#acknowledge"
]
},
"subject": {
"type": "union",
"refs": [
"com.atproto.admin.repo#view",
"com.atproto.admin.record#view"
]
},
"reason": {"type": "string"},
"createdBy": {"type": "string"},
"createdAt": {"type": "string"}
"createdAt": {"type": "string"},
"reversal": {"type": "ref", "ref": "#reversal"},
"resolvedReports": {"type": "array", "items": {"type": "ref", "ref": "com.atproto.admin.moderationReport#view"}}
}
},
"resolvedReport": {
"reversal": {
"type": "object",
"required": ["id"],
"required": ["reason", "createdBy", "createdAt"],
"properties": {
"id": {"type": "integer"}
"reason": {"type": "string"},
"createdBy": {"type": "string"},
"createdAt": {"type": "string"}
}
},
"takedown": {
Expand Down
44 changes: 44 additions & 0 deletions lexicons/com/atproto/admin/moderationReport.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"lexicon": 1,
"id": "com.atproto.admin.moderationReport",
"defs": {
"view": {
"type": "object",
"required": ["id", "reasonType", "subject", "reportedByDid", "createdAt", "resolvedByActionIds"],
"properties": {
"id": {"type": "integer"},
"reasonType": {"type": "ref", "ref": "com.atproto.report.reasonType"},
"reason": {"type": "string"},
"subject": {
"type": "union",
"refs": [
"com.atproto.repo.repoRef",
"com.atproto.repo.strongRef"
]
},
"reportedByDid": {"type": "string"},
"createdAt": {"type": "datetime"},
"resolvedByActionIds": {"type": "array", "items": {"type": "integer"}}
}
},
"viewDetail": {
"type": "object",
"required": ["id", "reasonType", "subject", "reportedByDid", "createdAt", "resolvedByActions"],
"properties": {
"id": {"type": "integer"},
"reasonType": {"type": "ref", "ref": "com.atproto.report.reasonType"},
"reason": {"type": "string"},
"subject": {
"type": "union",
"refs": [
"com.atproto.admin.repo#view",
"com.atproto.admin.record#view"
]
},
"reportedByDid": {"type": "string"},
"createdAt": {"type": "datetime"},
"resolvedByActions": {"type": "array", "items": {"type": "ref", "ref": "com.atproto.admin.moderationAction#view"}}
}
}
}
}
46 changes: 46 additions & 0 deletions lexicons/com/atproto/admin/record.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"lexicon": 1,
"id": "com.atproto.admin.record",
"defs": {
"view": {
"type": "object",
"required": ["uri", "cid", "value", "indexedAt", "moderation", "repo"],
"properties": {
"uri": {"type": "string"},
"cid": {"type": "string"},
"value": {"type": "unknown"},
"indexedAt": {"type": "string"},
"moderation": {"type": "ref", "ref": "#moderation"},
"repo": {"type": "ref", "ref": "com.atproto.admin.repo#view"}
}
},
"viewDetail": {
"type": "object",
"required": ["uri", "cid", "value", "indexedAt", "moderation", "repo"],
"properties": {
"uri": {"type": "string"},
"cid": {"type": "string"},
"value": {"type": "unknown"},
"indexedAt": {"type": "string"},
"moderation": {"type": "ref", "ref": "#moderationDetail"},
"repo": {"type": "ref", "ref": "com.atproto.admin.repo#view"}
}
},
"moderation": {
"type": "object",
"required": [],
"properties": {
"takedownId": {"type": "integer"}
}
},
"moderationDetail": {
"type": "object",
"required": ["actions", "reports"],
"properties": {
"actions": {"type": "array", "items": {"type": "ref", "ref": "com.atproto.admin.moderationAction#view"}},
"reports": {"type": "array", "items": {"type": "ref", "ref": "com.atproto.admin.moderationReport#view"}},
"takedownId": {"type": "integer"}
}
}
}
}
53 changes: 53 additions & 0 deletions lexicons/com/atproto/admin/repo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"lexicon": 1,
"id": "com.atproto.admin.repo",
"defs": {
"view": {
"type": "object",
"required": ["did", "handle", "relatedRecords", "indexedAt", "moderation"],
"properties": {
"did": {"type": "string"},
"handle": {"type": "string"},
"account": {"type": "ref", "ref": "#account"},
"relatedRecords": {"type": "array", "items": {"type": "unknown"}},
"indexedAt": {"type": "string"},
"moderation": {"type": "ref", "ref": "#moderation"}
}
},
"viewDetail": {
"type": "object",
"required": ["did", "handle", "relatedRecords", "indexedAt", "moderation"],
"properties": {
"did": {"type": "string"},
"handle": {"type": "string"},
"account": {"type": "ref", "ref": "#account"},
"relatedRecords": {"type": "array", "items": {"type": "unknown"}},
"indexedAt": {"type": "string"},
"moderation": {"type": "ref", "ref": "#moderationDetail"}
}
},
"account": {
"type": "object",
"required": ["email"],
"properties": {
"email": {"type": "string"}
}
},
"moderation": {
"type": "object",
"required": [],
"properties": {
"takedownId": {"type": "integer"}
}
},
"moderationDetail": {
"type": "object",
"required": ["actions", "reports"],
"properties": {
"actions": {"type": "array", "items": {"type": "ref", "ref": "com.atproto.admin.moderationAction#view"}},
"reports": {"type": "array", "items": {"type": "ref", "ref": "com.atproto.admin.moderationReport#view"}},
"takedownId": {"type": "integer"}
}
}
}
}
29 changes: 29 additions & 0 deletions lexicons/com/atproto/admin/searchRepos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"lexicon": 1,
"id": "com.atproto.admin.searchRepos",
"defs": {
"main": {
"type": "query",
"description": "Find repositories based on a search term.",
"parameters": {
"type": "params",
"properties": {
"term": {"type": "string"},
"limit": {"type": "integer", "minimum": 1, "maximum": 100, "default": 50},
"before": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["repos"],
"properties": {
"cursor": {"type": "string"},
"repos": {"type": "array", "items": {"type": "ref", "ref": "com.atproto.admin.repo#view"}}
}
}
}
}
}
}
Loading

0 comments on commit 13dd58b

Please sign in to comment.