Skip to content

Commit

Permalink
✨ Add events for account and record update/delete/deactivation (blues…
Browse files Browse the repository at this point in the history
…ky-social#2661)

* ✨ Add events for account and record update/delete/deactivation

* ✨ Add handle change event

* ✨ Reduce account events to 2 types and record events to 1

* ✨ Store metadata from account, identity and record events

* ✨ Add created event for record

* ✨ Add ndd the new events to allowed types in emitEvent

* ✨ Use string value for record op and add tombstone flag to identity event

* ✨ Add active flag on account events

* ✨ Change accountStatus -> status to match with firehose event

* ✨ Make active flag required

* 🚨 fix prettier style issue

* ✨ Track record/account delete and update data in subject status (bluesky-social#2804)

* ✨ Store deleted/updated event data in subject_status

* 🐛 Fix query for recordDeletedAt and recordUpdatedAt

* ✨ Add tombstoned status

* ✨ Move from record to hosting term

* ✅ Add tests for hosting params

* ✨ Update lexicons for hostingStatuses

* ✅ Update snapshots

* ✅ Update snapshots

* ✅ Update snapshots

* ✨ Adjust hosting statuses

* 📝 Add changeset
  • Loading branch information
foysalit authored Nov 7, 2024
1 parent c4b5e53 commit d6f33b4
Show file tree
Hide file tree
Showing 33 changed files with 1,708 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changeset/clever-beers-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@atproto/ozone": patch
"@atproto/api": patch
---

Add mod events and status filter for account and record hosting status
128 changes: 126 additions & 2 deletions lexicons/tools/ozone/moderation/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
"#modEventEmail",
"#modEventResolveAppeal",
"#modEventDivert",
"#modEventTag"
"#modEventTag",
"#accountEvent",
"#identityEvent",
"#recordEvent"
]
},
"subject": {
Expand Down Expand Up @@ -78,7 +81,10 @@
"#modEventEmail",
"#modEventResolveAppeal",
"#modEventDivert",
"#modEventTag"
"#modEventTag",
"#accountEvent",
"#identityEvent",
"#recordEvent"
]
},
"subject": {
Expand Down Expand Up @@ -110,6 +116,10 @@
"com.atproto.repo.strongRef"
]
},
"hosting": {
"type": "union",
"refs": ["#accountHosting", "#recordHosting"]
},
"subjectBlobCids": {
"type": "array",
"items": { "type": "string", "format": "cid" }
Expand Down Expand Up @@ -390,6 +400,62 @@
}
}
},
"accountEvent": {
"type": "object",
"description": "Logs account status related events on a repo subject. Normally captured by automod from the firehose and emitted to ozone for historical tracking.",
"required": ["timestamp", "active"],
"properties": {
"comment": { "type": "string" },
"active": {
"type": "boolean",
"description": "Indicates that the account has a repository which can be fetched from the host that emitted this event."
},
"status": {
"type": "string",
"knownValues": [
"unknown",
"deactivated",
"deleted",
"takendown",
"suspended",
"tombstoned"
]
},
"timestamp": {
"type": "string",
"format": "datetime"
}
}
},
"identityEvent": {
"type": "object",
"description": "Logs identity related events on a repo subject. Normally captured by automod from the firehose and emitted to ozone for historical tracking.",
"required": ["timestamp"],
"properties": {
"comment": { "type": "string" },
"handle": { "type": "string", "format": "handle" },
"pdsHost": { "type": "string", "format": "uri" },
"tombstone": { "type": "boolean" },
"timestamp": {
"type": "string",
"format": "datetime"
}
}
},
"recordEvent": {
"type": "object",
"description": "Logs lifecycle event on a record subject. Normally captured by automod from the firehose and emitted to ozone for historical tracking.",
"required": ["timestamp", "op"],
"properties": {
"comment": { "type": "string" },
"op": {
"type": "string",
"knownValues": ["create", "update", "delete"]
},
"cid": { "type": "string", "format": "cid" },
"timestamp": { "type": "string", "format": "datetime" }
}
},
"repoView": {
"type": "object",
"required": [
Expand Down Expand Up @@ -578,6 +644,64 @@
"height": { "type": "integer" },
"length": { "type": "integer" }
}
},
"accountHosting": {
"type": "object",
"required": ["status"],
"properties": {
"status": {
"type": "string",
"knownValues": [
"takendown",
"suspended",
"deleted",
"deactivated",
"unknown"
]
},
"updatedAt": {
"type": "string",
"format": "datetime"
},
"createdAt": {
"type": "string",
"format": "datetime"
},
"deletedAt": {
"type": "string",
"format": "datetime"
},
"deactivatedAt": {
"type": "string",
"format": "datetime"
},
"reactivatedAt": {
"type": "string",
"format": "datetime"
}
}
},
"recordHosting": {
"type": "object",
"required": ["status"],
"properties": {
"status": {
"type": "string",
"knownValues": ["deleted", "unknown"]
},
"updatedAt": {
"type": "string",
"format": "datetime"
},
"createdAt": {
"type": "string",
"format": "datetime"
},
"deletedAt": {
"type": "string",
"format": "datetime"
}
}
}
}
}
5 changes: 4 additions & 1 deletion lexicons/tools/ozone/moderation/emitEvent.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
"tools.ozone.moderation.defs#modEventReverseTakedown",
"tools.ozone.moderation.defs#modEventResolveAppeal",
"tools.ozone.moderation.defs#modEventEmail",
"tools.ozone.moderation.defs#modEventTag"
"tools.ozone.moderation.defs#modEventTag",
"tools.ozone.moderation.defs#accountEvent",
"tools.ozone.moderation.defs#identityEvent",
"tools.ozone.moderation.defs#recordEvent"
]
},
"subject": {
Expand Down
27 changes: 27 additions & 0 deletions lexicons/tools/ozone/moderation/queryStatuses.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,33 @@
"format": "datetime",
"description": "Search subjects reviewed after a given timestamp"
},
"hostingDeletedAfter": {
"type": "string",
"format": "datetime",
"description": "Search subjects where the associated record/account was deleted after a given timestamp"
},
"hostingDeletedBefore": {
"type": "string",
"format": "datetime",
"description": "Search subjects where the associated record/account was deleted before a given timestamp"
},
"hostingUpdatedAfter": {
"type": "string",
"format": "datetime",
"description": "Search subjects where the associated record/account was updated after a given timestamp"
},
"hostingUpdatedBefore": {
"type": "string",
"format": "datetime",
"description": "Search subjects where the associated record/account was updated before a given timestamp"
},
"hostingStatuses": {
"type": "array",
"items": {
"type": "string"
},
"description": "Search subjects by the status of the associated record/account"
},
"reviewedBefore": {
"type": "string",
"format": "datetime",
Expand Down
Loading

0 comments on commit d6f33b4

Please sign in to comment.