Skip to content

Commit

Permalink
Incorporate blobs into moderation actions (bluesky-social#511)
Browse files Browse the repository at this point in the history
* Lexicon updates for moderating blobs

* Add tracking of blob takedowns to moderation system

* Handle blobs in record takedown reversal

* Apply blob takedowns w/ image invalidation

* Test blob takedowns

* Implement cloudfront image invalidator

* Update lexicons for current moderation action on records and blobs

* Fix migration for postgres

* Enforce single current action per repo and blob, present current action on repo and blob

* Test single active mod action per repo, record, and blob

* Continue to resolve handles for moderated repos
  • Loading branch information
devinivy authored Feb 6, 2023
1 parent 64f5b4a commit b91e6e9
Show file tree
Hide file tree
Showing 49 changed files with 2,308 additions and 190 deletions.
45 changes: 45 additions & 0 deletions lexicons/com/atproto/admin/blob.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"lexicon": 1,
"id": "com.atproto.admin.blob",
"defs": {
"view": {
"type": "object",
"required": ["cid", "mimeType", "size", "createdAt"],
"properties": {
"cid": {"type": "string"},
"mimeType": {"type": "string"},
"size": {"type": "integer"},
"createdAt": {"type": "datetime"},
"details": {
"type": "union",
"refs": ["#imageDetails", "#videoDetails"]
},
"moderation": {"type": "ref", "ref": "#moderation"}
}
},
"imageDetails": {
"type": "object",
"required": ["width", "height"],
"properties": {
"width": {"type": "integer"},
"height": {"type": "integer"}
}
},
"videoDetails": {
"type": "object",
"required": ["width", "height", "length"],
"properties": {
"width": {"type": "integer"},
"height": {"type": "integer"},
"length": {"type": "integer"}
}
},
"moderation": {
"type": "object",
"required": [],
"properties": {
"currentAction": {"type": "ref", "ref": "com.atproto.admin.moderationAction#viewCurrent"}
}
}
}
}
40 changes: 22 additions & 18 deletions lexicons/com/atproto/admin/moderationAction.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,18 @@
"defs": {
"view": {
"type": "object",
"required": ["id", "action", "subject", "reason", "createdBy", "createdAt", "resolvedReportIds"],
"required": ["id", "action", "subject", "subjectBlobCids", "reason", "createdBy", "createdAt", "resolvedReportIds"],
"properties": {
"id": {"type": "integer"},
"action": {
"type": "string",
"knownValues": [
"com.atproto.admin.moderationAction#takedown",
"com.atproto.admin.moderationAction#flag",
"com.atproto.admin.moderationAction#acknowledge"
]
},
"action": {"type": "ref", "ref": "#actionType"},
"subject": {
"type": "union",
"refs": [
"com.atproto.repo.repoRef",
"com.atproto.repo.strongRef"
]
},
"subjectBlobCids": {"type": "array", "items": {"type": "string"}},
"reason": {"type": "string"},
"createdBy": {"type": "string"},
"createdAt": {"type": "string"},
Expand All @@ -31,31 +25,33 @@
},
"viewDetail": {
"type": "object",
"required": ["id", "action", "subject", "reason", "createdBy", "createdAt", "resolvedReports"],
"required": ["id", "action", "subject", "subjectBlobs", "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"
]
},
"action": {"type": "ref", "ref": "#actionType"},
"subject": {
"type": "union",
"refs": [
"com.atproto.admin.repo#view",
"com.atproto.admin.record#view"
]
},
"subjectBlobs": {"type": "array", "items": {"type": "ref", "ref": "com.atproto.admin.blob#view"}},
"reason": {"type": "string"},
"createdBy": {"type": "string"},
"createdAt": {"type": "string"},
"reversal": {"type": "ref", "ref": "#reversal"},
"resolvedReports": {"type": "array", "items": {"type": "ref", "ref": "com.atproto.admin.moderationReport#view"}}
}
},
"viewCurrent": {
"type": "object",
"required": ["id", "action"],
"properties": {
"id": {"type": "integer"},
"action": {"type": "ref", "ref": "#actionType"}
}
},
"reversal": {
"type": "object",
"required": ["reason", "createdBy", "createdAt"],
Expand All @@ -65,6 +61,14 @@
"createdAt": {"type": "string"}
}
},
"actionType": {
"type": "string",
"knownValues": [
"com.atproto.admin.moderationAction#takedown",
"com.atproto.admin.moderationAction#flag",
"com.atproto.admin.moderationAction#acknowledge"
]
},
"takedown": {
"type": "token",
"description": "Moderation action type: Takedown. Indicates that content should not be served by the PDS."
Expand Down
12 changes: 7 additions & 5 deletions lexicons/com/atproto/admin/record.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@
"defs": {
"view": {
"type": "object",
"required": ["uri", "cid", "value", "indexedAt", "moderation", "repo"],
"required": ["uri", "cid", "value", "blobCids", "indexedAt", "moderation", "repo"],
"properties": {
"uri": {"type": "string"},
"cid": {"type": "string"},
"value": {"type": "unknown"},
"blobCids": {"type": "array", "items": {"type": "string"}},
"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"],
"required": ["uri", "cid", "value", "blobs", "indexedAt", "moderation", "repo"],
"properties": {
"uri": {"type": "string"},
"cid": {"type": "string"},
"value": {"type": "unknown"},
"blobs": {"type": "array", "items": {"type": "ref", "ref": "com.atproto.admin.blob#view"}},
"indexedAt": {"type": "string"},
"moderation": {"type": "ref", "ref": "#moderationDetail"},
"repo": {"type": "ref", "ref": "com.atproto.admin.repo#view"}
Expand All @@ -30,16 +32,16 @@
"type": "object",
"required": [],
"properties": {
"takedownId": {"type": "integer"}
"currentAction": {"type": "ref", "ref": "com.atproto.admin.moderationAction#viewCurrent"}
}
},
"moderationDetail": {
"type": "object",
"required": ["actions", "reports"],
"properties": {
"currentAction": {"type": "ref", "ref": "com.atproto.admin.moderationAction#viewCurrent"},
"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"}
"reports": {"type": "array", "items": {"type": "ref", "ref": "com.atproto.admin.moderationReport#view"}}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions lexicons/com/atproto/admin/repo.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@
"type": "object",
"required": [],
"properties": {
"takedownId": {"type": "integer"}
"currentAction": {"type": "ref", "ref": "com.atproto.admin.moderationAction#viewCurrent"}
}
},
"moderationDetail": {
"type": "object",
"required": ["actions", "reports"],
"properties": {
"currentAction": {"type": "ref", "ref": "com.atproto.admin.moderationAction#viewCurrent"},
"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"}
"reports": {"type": "array", "items": {"type": "ref", "ref": "com.atproto.admin.moderationReport#view"}}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion lexicons/com/atproto/admin/takeModerationAction.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"com.atproto.repo.recordRef"
]
},
"subjectBlobCids": {"type": "array", "items": {"type": "string"}},
"reason": {"type": "string"},
"createdBy": {"type": "string"}
}
Expand All @@ -37,7 +38,8 @@
"type": "ref",
"ref": "com.atproto.admin.moderationAction#view"
}
}
},
"errors": [{ "name": "SubjectHasAction" }]
}
}
}
2 changes: 2 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import * as ComAtprotoAccountGet from './types/com/atproto/account/get'
import * as ComAtprotoAccountRequestDelete from './types/com/atproto/account/requestDelete'
import * as ComAtprotoAccountRequestPasswordReset from './types/com/atproto/account/requestPasswordReset'
import * as ComAtprotoAccountResetPassword from './types/com/atproto/account/resetPassword'
import * as ComAtprotoAdminBlob from './types/com/atproto/admin/blob'
import * as ComAtprotoAdminGetModerationAction from './types/com/atproto/admin/getModerationAction'
import * as ComAtprotoAdminGetModerationActions from './types/com/atproto/admin/getModerationActions'
import * as ComAtprotoAdminGetModerationReport from './types/com/atproto/admin/getModerationReport'
Expand Down Expand Up @@ -95,6 +96,7 @@ export * as ComAtprotoAccountGet from './types/com/atproto/account/get'
export * as ComAtprotoAccountRequestDelete from './types/com/atproto/account/requestDelete'
export * as ComAtprotoAccountRequestPasswordReset from './types/com/atproto/account/requestPasswordReset'
export * as ComAtprotoAccountResetPassword from './types/com/atproto/account/resetPassword'
export * as ComAtprotoAdminBlob from './types/com/atproto/admin/blob'
export * as ComAtprotoAdminGetModerationAction from './types/com/atproto/admin/getModerationAction'
export * as ComAtprotoAdminGetModerationActions from './types/com/atproto/admin/getModerationActions'
export * as ComAtprotoAdminGetModerationReport from './types/com/atproto/admin/getModerationReport'
Expand Down
Loading

0 comments on commit b91e6e9

Please sign in to comment.