{
	"lexicon": 1,
	"id": "tools.ozone.moderation.defs",
	"defs": {
		"modEventView": {
			"type": "object",
			"required": ["id", "event", "subject", "subjectBlobCids", "createdBy", "createdAt"],
			"properties": {
				"id": { "type": "integer" },
				"event": {
					"type": "union",
					"refs": [
						"#modEventTakedown",
						"#modEventReverseTakedown",
						"#modEventComment",
						"#modEventReport",
						"#modEventLabel",
						"#modEventAcknowledge",
						"#modEventEscalate",
						"#modEventMute",
						"#modEventUnmute",
						"#modEventMuteReporter",
						"#modEventUnmuteReporter",
						"#modEventEmail",
						"#modEventResolveAppeal",
						"#modEventDivert",
						"#modEventTag",
						"#accountEvent",
						"#identityEvent",
						"#recordEvent"
					]
				},
				"subject": {
					"type": "union",
					"refs": [
						"com.atproto.admin.defs#repoRef",
						"com.atproto.repo.strongRef",
						"chat.bsky.convo.defs#messageRef"
					]
				},
				"subjectBlobCids": { "type": "array", "items": { "type": "string" } },
				"createdBy": { "type": "string", "format": "did" },
				"createdAt": { "type": "string", "format": "datetime" },
				"creatorHandle": { "type": "string" },
				"subjectHandle": { "type": "string" }
			}
		},
		"modEventViewDetail": {
			"type": "object",
			"required": ["id", "event", "subject", "subjectBlobs", "createdBy", "createdAt"],
			"properties": {
				"id": { "type": "integer" },
				"event": {
					"type": "union",
					"refs": [
						"#modEventTakedown",
						"#modEventReverseTakedown",
						"#modEventComment",
						"#modEventReport",
						"#modEventLabel",
						"#modEventAcknowledge",
						"#modEventEscalate",
						"#modEventMute",
						"#modEventUnmute",
						"#modEventMuteReporter",
						"#modEventUnmuteReporter",
						"#modEventEmail",
						"#modEventResolveAppeal",
						"#modEventDivert",
						"#modEventTag",
						"#accountEvent",
						"#identityEvent",
						"#recordEvent"
					]
				},
				"subject": {
					"type": "union",
					"refs": ["#repoView", "#repoViewNotFound", "#recordView", "#recordViewNotFound"]
				},
				"subjectBlobs": {
					"type": "array",
					"items": { "type": "ref", "ref": "#blobView" }
				},
				"createdBy": { "type": "string", "format": "did" },
				"createdAt": { "type": "string", "format": "datetime" }
			}
		},
		"subjectStatusView": {
			"type": "object",
			"required": ["id", "subject", "createdAt", "updatedAt", "reviewState"],
			"properties": {
				"id": { "type": "integer" },
				"subject": {
					"type": "union",
					"refs": ["com.atproto.admin.defs#repoRef", "com.atproto.repo.strongRef"]
				},
				"hosting": {
					"type": "union",
					"refs": ["#accountHosting", "#recordHosting"]
				},
				"subjectBlobCids": {
					"type": "array",
					"items": { "type": "string", "format": "cid" }
				},
				"subjectRepoHandle": { "type": "string" },
				"updatedAt": {
					"type": "string",
					"format": "datetime",
					"description": "Timestamp referencing when the last update was made to the moderation status of the subject"
				},
				"createdAt": {
					"type": "string",
					"format": "datetime",
					"description": "Timestamp referencing the first moderation status impacting event was emitted on the subject"
				},
				"reviewState": {
					"type": "ref",
					"ref": "#subjectReviewState"
				},
				"comment": {
					"type": "string",
					"description": "Sticky comment on the subject."
				},
				"muteUntil": {
					"type": "string",
					"format": "datetime"
				},
				"muteReportingUntil": {
					"type": "string",
					"format": "datetime"
				},
				"lastReviewedBy": {
					"type": "string",
					"format": "did"
				},
				"lastReviewedAt": {
					"type": "string",
					"format": "datetime"
				},
				"lastReportedAt": {
					"type": "string",
					"format": "datetime"
				},
				"lastAppealedAt": {
					"type": "string",
					"format": "datetime",
					"description": "Timestamp referencing when the author of the subject appealed a moderation action"
				},
				"takendown": {
					"type": "boolean"
				},
				"appealed": {
					"type": "boolean",
					"description": "True indicates that the a previously taken moderator action was appealed against, by the author of the content. False indicates last appeal was resolved by moderators."
				},
				"suspendUntil": {
					"type": "string",
					"format": "datetime"
				},
				"tags": {
					"type": "array",
					"items": { "type": "string" }
				}
			}
		},
		"subjectReviewState": {
			"type": "string",
			"knownValues": ["#reviewOpen", "#reviewEscalated", "#reviewClosed", "#reviewNone"]
		},
		"reviewOpen": {
			"type": "token",
			"description": "Moderator review status of a subject: Open. Indicates that the subject needs to be reviewed by a moderator"
		},
		"reviewEscalated": {
			"type": "token",
			"description": "Moderator review status of a subject: Escalated. Indicates that the subject was escalated for review by a moderator"
		},
		"reviewClosed": {
			"type": "token",
			"description": "Moderator review status of a subject: Closed. Indicates that the subject was already reviewed and resolved by a moderator"
		},
		"reviewNone": {
			"type": "token",
			"description": "Moderator review status of a subject: Unnecessary. Indicates that the subject does not need a review at the moment but there is probably some moderation related metadata available for it"
		},
		"modEventTakedown": {
			"type": "object",
			"description": "Take down a subject permanently or temporarily",
			"properties": {
				"comment": {
					"type": "string"
				},
				"durationInHours": {
					"type": "integer",
					"description": "Indicates how long the takedown should be in effect before automatically expiring."
				},
				"acknowledgeAccountSubjects": {
					"type": "boolean",
					"description": "If true, all other reports on content authored by this account will be resolved (acknowledged)."
				},
				"policies": {
					"type": "array",
					"maxLength": 5,
					"items": { "type": "string" },
					"description": "Names/Keywords of the policies that drove the decision."
				}
			}
		},
		"modEventReverseTakedown": {
			"type": "object",
			"description": "Revert take down action on a subject",
			"properties": {
				"comment": {
					"type": "string",
					"description": "Describe reasoning behind the reversal."
				}
			}
		},
		"modEventResolveAppeal": {
			"type": "object",
			"description": "Resolve appeal on a subject",
			"properties": {
				"comment": {
					"type": "string",
					"description": "Describe resolution."
				}
			}
		},
		"modEventComment": {
			"type": "object",
			"description": "Add a comment to a subject",
			"required": ["comment"],
			"properties": {
				"comment": {
					"type": "string"
				},
				"sticky": {
					"type": "boolean",
					"description": "Make the comment persistent on the subject"
				}
			}
		},
		"modEventReport": {
			"type": "object",
			"description": "Report a subject",
			"required": ["reportType"],
			"properties": {
				"comment": {
					"type": "string"
				},
				"isReporterMuted": {
					"type": "boolean",
					"description": "Set to true if the reporter was muted from reporting at the time of the event. These reports won't impact the reviewState of the subject."
				},
				"reportType": {
					"type": "ref",
					"ref": "com.atproto.moderation.defs#reasonType"
				}
			}
		},
		"modEventLabel": {
			"type": "object",
			"description": "Apply/Negate labels on a subject",
			"required": ["createLabelVals", "negateLabelVals"],
			"properties": {
				"comment": {
					"type": "string"
				},
				"createLabelVals": {
					"type": "array",
					"items": { "type": "string" }
				},
				"negateLabelVals": {
					"type": "array",
					"items": { "type": "string" }
				}
			}
		},
		"modEventAcknowledge": {
			"type": "object",
			"properties": {
				"comment": { "type": "string" },
				"acknowledgeAccountSubjects": {
					"type": "boolean",
					"description": "If true, all other reports on content authored by this account will be resolved (acknowledged)."
				}
			}
		},
		"modEventEscalate": {
			"type": "object",
			"properties": {
				"comment": { "type": "string" }
			}
		},
		"modEventMute": {
			"type": "object",
			"description": "Mute incoming reports on a subject",
			"required": ["durationInHours"],
			"properties": {
				"comment": { "type": "string" },
				"durationInHours": {
					"type": "integer",
					"description": "Indicates how long the subject should remain muted."
				}
			}
		},
		"modEventUnmute": {
			"type": "object",
			"description": "Unmute action on a subject",
			"properties": {
				"comment": {
					"type": "string",
					"description": "Describe reasoning behind the reversal."
				}
			}
		},
		"modEventMuteReporter": {
			"type": "object",
			"description": "Mute incoming reports from an account",
			"properties": {
				"comment": { "type": "string" },
				"durationInHours": {
					"type": "integer",
					"description": "Indicates how long the account should remain muted. Falsy value here means a permanent mute."
				}
			}
		},
		"modEventUnmuteReporter": {
			"type": "object",
			"description": "Unmute incoming reports from an account",
			"properties": {
				"comment": {
					"type": "string",
					"description": "Describe reasoning behind the reversal."
				}
			}
		},
		"modEventEmail": {
			"type": "object",
			"description": "Keep a log of outgoing email to a user",
			"required": ["subjectLine"],
			"properties": {
				"subjectLine": {
					"type": "string",
					"description": "The subject line of the email sent to the user."
				},
				"content": {
					"type": "string",
					"description": "The content of the email sent to the user."
				},
				"comment": {
					"type": "string",
					"description": "Additional comment about the outgoing comm."
				}
			}
		},
		"modEventDivert": {
			"type": "object",
			"description": "Divert a record's blobs to a 3rd party service for further scanning/tagging",
			"properties": {
				"comment": { "type": "string" }
			}
		},
		"modEventTag": {
			"type": "object",
			"description": "Add/Remove a tag on a subject",
			"required": ["add", "remove"],
			"properties": {
				"add": {
					"type": "array",
					"items": { "type": "string" },
					"description": "Tags to be added to the subject. If already exists, won't be duplicated."
				},
				"remove": {
					"type": "array",
					"items": { "type": "string" },
					"description": "Tags to be removed to the subject. Ignores a tag If it doesn't exist, won't be duplicated."
				},
				"comment": {
					"type": "string",
					"description": "Additional comment about added/removed tags."
				}
			}
		},
		"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": ["did", "handle", "relatedRecords", "indexedAt", "moderation"],
			"properties": {
				"did": { "type": "string", "format": "did" },
				"handle": { "type": "string", "format": "handle" },
				"email": { "type": "string" },
				"relatedRecords": { "type": "array", "items": { "type": "unknown" } },
				"indexedAt": { "type": "string", "format": "datetime" },
				"moderation": { "type": "ref", "ref": "#moderation" },
				"invitedBy": {
					"type": "ref",
					"ref": "com.atproto.server.defs#inviteCode"
				},
				"invitesDisabled": { "type": "boolean" },
				"inviteNote": { "type": "string" },
				"deactivatedAt": { "type": "string", "format": "datetime" },
				"threatSignatures": {
					"type": "array",
					"items": {
						"type": "ref",
						"ref": "com.atproto.admin.defs#threatSignature"
					}
				}
			}
		},
		"repoViewDetail": {
			"type": "object",
			"required": ["did", "handle", "relatedRecords", "indexedAt", "moderation"],
			"properties": {
				"did": { "type": "string", "format": "did" },
				"handle": { "type": "string", "format": "handle" },
				"email": { "type": "string" },
				"relatedRecords": { "type": "array", "items": { "type": "unknown" } },
				"indexedAt": { "type": "string", "format": "datetime" },
				"moderation": { "type": "ref", "ref": "#moderationDetail" },
				"labels": {
					"type": "array",
					"items": { "type": "ref", "ref": "com.atproto.label.defs#label" }
				},
				"invitedBy": {
					"type": "ref",
					"ref": "com.atproto.server.defs#inviteCode"
				},
				"invites": {
					"type": "array",
					"items": {
						"type": "ref",
						"ref": "com.atproto.server.defs#inviteCode"
					}
				},
				"invitesDisabled": { "type": "boolean" },
				"inviteNote": { "type": "string" },
				"emailConfirmedAt": { "type": "string", "format": "datetime" },
				"deactivatedAt": { "type": "string", "format": "datetime" },
				"threatSignatures": {
					"type": "array",
					"items": {
						"type": "ref",
						"ref": "com.atproto.admin.defs#threatSignature"
					}
				}
			}
		},
		"repoViewNotFound": {
			"type": "object",
			"required": ["did"],
			"properties": {
				"did": { "type": "string", "format": "did" }
			}
		},
		"recordView": {
			"type": "object",
			"required": ["uri", "cid", "value", "blobCids", "indexedAt", "moderation", "repo"],
			"properties": {
				"uri": { "type": "string", "format": "at-uri" },
				"cid": { "type": "string", "format": "cid" },
				"value": { "type": "unknown" },
				"blobCids": {
					"type": "array",
					"items": { "type": "string", "format": "cid" }
				},
				"indexedAt": { "type": "string", "format": "datetime" },
				"moderation": { "type": "ref", "ref": "#moderation" },
				"repo": { "type": "ref", "ref": "#repoView" }
			}
		},
		"recordViewDetail": {
			"type": "object",
			"required": ["uri", "cid", "value", "blobs", "indexedAt", "moderation", "repo"],
			"properties": {
				"uri": { "type": "string", "format": "at-uri" },
				"cid": { "type": "string", "format": "cid" },
				"value": { "type": "unknown" },
				"blobs": {
					"type": "array",
					"items": { "type": "ref", "ref": "#blobView" }
				},
				"labels": {
					"type": "array",
					"items": { "type": "ref", "ref": "com.atproto.label.defs#label" }
				},
				"indexedAt": { "type": "string", "format": "datetime" },
				"moderation": { "type": "ref", "ref": "#moderationDetail" },
				"repo": { "type": "ref", "ref": "#repoView" }
			}
		},
		"recordViewNotFound": {
			"type": "object",
			"required": ["uri"],
			"properties": {
				"uri": { "type": "string", "format": "at-uri" }
			}
		},
		"moderation": {
			"type": "object",
			"properties": {
				"subjectStatus": { "type": "ref", "ref": "#subjectStatusView" }
			}
		},
		"moderationDetail": {
			"type": "object",
			"properties": {
				"subjectStatus": {
					"type": "ref",
					"ref": "#subjectStatusView"
				}
			}
		},
		"blobView": {
			"type": "object",
			"required": ["cid", "mimeType", "size", "createdAt"],
			"properties": {
				"cid": { "type": "string", "format": "cid" },
				"mimeType": { "type": "string" },
				"size": { "type": "integer" },
				"createdAt": { "type": "string", "format": "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" }
			}
		},
		"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"
				}
			}
		}
	}
}
