Skip to content

Commit

Permalink
Add threat signatures to admin view (bluesky-social#2929)
Browse files Browse the repository at this point in the history
* add threat signatures to admin view

* codegne
  • Loading branch information
dholms authored Oct 30, 2024
1 parent 19e36af commit 0158ab3
Show file tree
Hide file tree
Showing 15 changed files with 198 additions and 25 deletions.
17 changes: 16 additions & 1 deletion lexicons/com/atproto/admin/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@
"invitesDisabled": { "type": "boolean" },
"emailConfirmedAt": { "type": "string", "format": "datetime" },
"inviteNote": { "type": "string" },
"deactivatedAt": { "type": "string", "format": "datetime" }
"deactivatedAt": { "type": "string", "format": "datetime" },
"threatSignatures": {
"type": "array",
"items": {
"type": "ref",
"ref": "#threatSignature"
}
}
}
},
"repoRef": {
Expand All @@ -51,6 +58,14 @@
"cid": { "type": "string", "format": "cid" },
"recordUri": { "type": "string", "format": "at-uri" }
}
},
"threatSignature": {
"type": "object",
"required": ["property", "value"],
"properties": {
"property": { "type": "string" },
"value": { "type": "string" }
}
}
}
}
29 changes: 25 additions & 4 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ export const schemaDict = {
type: 'string',
format: 'datetime',
},
threatSignatures: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:com.atproto.admin.defs#threatSignature',
},
},
},
},
repoRef: {
Expand Down Expand Up @@ -100,6 +107,18 @@ export const schemaDict = {
},
},
},
threatSignature: {
type: 'object',
required: ['property', 'value'],
properties: {
property: {
type: 'string',
},
value: {
type: 'string',
},
},
},
},
},
ComAtprotoAdminDeleteAccount: {
Expand Down Expand Up @@ -11811,6 +11830,7 @@ export const schemaDict = {
},
collections: {
type: 'array',
maxLength: 20,
description:
"If specified, only events where the subject belongs to the given collections will be returned. When subjectType is set to 'account', this will be ignored.",
items: {
Expand All @@ -11821,14 +11841,14 @@ export const schemaDict = {
subjectType: {
type: 'string',
description:
"If specified, only events where the subject is of the given type (account or record) will be returned. When this is set to 'account' the 'collections' parameter will be ignored.",
"If specified, only events where the subject is of the given type (account or record) will be returned. When this is set to 'account' the 'collections' parameter will be ignored. When includeAllUserRecords or subject is set, this will be ignored.",
knownValues: ['account', 'record'],
},
includeAllUserRecords: {
type: 'boolean',
default: false,
description:
'If true, events on all record types (posts, lists, profile etc.) owned by the did are returned',
"If true, events on all record types (posts, lists, profile etc.) or records from given 'collections' param, owned by the did are returned.",
},
limit: {
type: 'integer',
Expand Down Expand Up @@ -11923,7 +11943,7 @@ export const schemaDict = {
includeAllUserRecords: {
type: 'boolean',
description:
"All subjects belonging to the account specified in the 'subject' param will be returned.",
"All subjects, or subjects from given 'collections' param, belonging to the account specified in the 'subject' param will be returned.",
},
subject: {
type: 'string',
Expand Down Expand Up @@ -12022,6 +12042,7 @@ export const schemaDict = {
},
collections: {
type: 'array',
maxLength: 20,
description:
"If specified, subjects belonging to the given collections will be returned. When subjectType is set to 'account', this will be ignored.",
items: {
Expand All @@ -12032,7 +12053,7 @@ export const schemaDict = {
subjectType: {
type: 'string',
description:
"If specified, subjects of the given type (account or record) will be returned. When this is set to 'account' the 'collections' parameter will be ignored.",
"If specified, subjects of the given type (account or record) will be returned. When this is set to 'account' the 'collections' parameter will be ignored. When includeAllUserRecords or subject is set, this will be ignored.",
knownValues: ['account', 'record'],
},
},
Expand Down
19 changes: 19 additions & 0 deletions packages/api/src/client/types/com/atproto/admin/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface AccountView {
emailConfirmedAt?: string
inviteNote?: string
deactivatedAt?: string
threatSignatures?: ThreatSignature[]
[k: string]: unknown
}

Expand Down Expand Up @@ -87,3 +88,21 @@ export function isRepoBlobRef(v: unknown): v is RepoBlobRef {
export function validateRepoBlobRef(v: unknown): ValidationResult {
return lexicons.validate('com.atproto.admin.defs#repoBlobRef', v)
}

export interface ThreatSignature {
property: string
value: string
[k: string]: unknown
}

export function isThreatSignature(v: unknown): v is ThreatSignature {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'com.atproto.admin.defs#threatSignature'
)
}

export function validateThreatSignature(v: unknown): ValidationResult {
return lexicons.validate('com.atproto.admin.defs#threatSignature', v)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export interface QueryParams {
subject?: string
/** If specified, only events where the subject belongs to the given collections will be returned. When subjectType is set to 'account', this will be ignored. */
collections?: string[]
/** If specified, only events where the subject is of the given type (account or record) will be returned. When this is set to 'account' the 'collections' parameter will be ignored. */
/** If specified, only events where the subject is of the given type (account or record) will be returned. When this is set to 'account' the 'collections' parameter will be ignored. When includeAllUserRecords or subject is set, this will be ignored. */
subjectType?: 'account' | 'record' | (string & {})
/** If true, events on all record types (posts, lists, profile etc.) owned by the did are returned */
/** If true, events on all record types (posts, lists, profile etc.) or records from given 'collections' param, owned by the did are returned. */
includeAllUserRecords?: boolean
limit?: number
/** If true, only events with comments are returned */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { CID } from 'multiformats/cid'
import * as ToolsOzoneModerationDefs from './defs'

export interface QueryParams {
/** All subjects belonging to the account specified in the 'subject' param will be returned. */
/** All subjects, or subjects from given 'collections' param, belonging to the account specified in the 'subject' param will be returned. */
includeAllUserRecords?: boolean
/** The subject to get the status for. */
subject?: string
Expand Down Expand Up @@ -44,7 +44,7 @@ export interface QueryParams {
cursor?: string
/** If specified, subjects belonging to the given collections will be returned. When subjectType is set to 'account', this will be ignored. */
collections?: string[]
/** If specified, subjects of the given type (account or record) will be returned. When this is set to 'account' the 'collections' parameter will be ignored. */
/** If specified, subjects of the given type (account or record) will be returned. When this is set to 'account' the 'collections' parameter will be ignored. When includeAllUserRecords or subject is set, this will be ignored. */
subjectType?: 'account' | 'record' | (string & {})
}

Expand Down
19 changes: 19 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ export const schemaDict = {
type: 'string',
format: 'datetime',
},
threatSignatures: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:com.atproto.admin.defs#threatSignature',
},
},
},
},
repoRef: {
Expand Down Expand Up @@ -100,6 +107,18 @@ export const schemaDict = {
},
},
},
threatSignature: {
type: 'object',
required: ['property', 'value'],
properties: {
property: {
type: 'string',
},
value: {
type: 'string',
},
},
},
},
},
ComAtprotoAdminDeleteAccount: {
Expand Down
19 changes: 19 additions & 0 deletions packages/bsky/src/lexicon/types/com/atproto/admin/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface AccountView {
emailConfirmedAt?: string
inviteNote?: string
deactivatedAt?: string
threatSignatures?: ThreatSignature[]
[k: string]: unknown
}

Expand Down Expand Up @@ -87,3 +88,21 @@ export function isRepoBlobRef(v: unknown): v is RepoBlobRef {
export function validateRepoBlobRef(v: unknown): ValidationResult {
return lexicons.validate('com.atproto.admin.defs#repoBlobRef', v)
}

export interface ThreatSignature {
property: string
value: string
[k: string]: unknown
}

export function isThreatSignature(v: unknown): v is ThreatSignature {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'com.atproto.admin.defs#threatSignature'
)
}

export function validateThreatSignature(v: unknown): ValidationResult {
return lexicons.validate('com.atproto.admin.defs#threatSignature', v)
}
29 changes: 25 additions & 4 deletions packages/ozone/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ export const schemaDict = {
type: 'string',
format: 'datetime',
},
threatSignatures: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:com.atproto.admin.defs#threatSignature',
},
},
},
},
repoRef: {
Expand Down Expand Up @@ -100,6 +107,18 @@ export const schemaDict = {
},
},
},
threatSignature: {
type: 'object',
required: ['property', 'value'],
properties: {
property: {
type: 'string',
},
value: {
type: 'string',
},
},
},
},
},
ComAtprotoAdminDeleteAccount: {
Expand Down Expand Up @@ -11811,6 +11830,7 @@ export const schemaDict = {
},
collections: {
type: 'array',
maxLength: 20,
description:
"If specified, only events where the subject belongs to the given collections will be returned. When subjectType is set to 'account', this will be ignored.",
items: {
Expand All @@ -11821,14 +11841,14 @@ export const schemaDict = {
subjectType: {
type: 'string',
description:
"If specified, only events where the subject is of the given type (account or record) will be returned. When this is set to 'account' the 'collections' parameter will be ignored.",
"If specified, only events where the subject is of the given type (account or record) will be returned. When this is set to 'account' the 'collections' parameter will be ignored. When includeAllUserRecords or subject is set, this will be ignored.",
knownValues: ['account', 'record'],
},
includeAllUserRecords: {
type: 'boolean',
default: false,
description:
'If true, events on all record types (posts, lists, profile etc.) owned by the did are returned',
"If true, events on all record types (posts, lists, profile etc.) or records from given 'collections' param, owned by the did are returned.",
},
limit: {
type: 'integer',
Expand Down Expand Up @@ -11923,7 +11943,7 @@ export const schemaDict = {
includeAllUserRecords: {
type: 'boolean',
description:
"All subjects belonging to the account specified in the 'subject' param will be returned.",
"All subjects, or subjects from given 'collections' param, belonging to the account specified in the 'subject' param will be returned.",
},
subject: {
type: 'string',
Expand Down Expand Up @@ -12022,6 +12042,7 @@ export const schemaDict = {
},
collections: {
type: 'array',
maxLength: 20,
description:
"If specified, subjects belonging to the given collections will be returned. When subjectType is set to 'account', this will be ignored.",
items: {
Expand All @@ -12032,7 +12053,7 @@ export const schemaDict = {
subjectType: {
type: 'string',
description:
"If specified, subjects of the given type (account or record) will be returned. When this is set to 'account' the 'collections' parameter will be ignored.",
"If specified, subjects of the given type (account or record) will be returned. When this is set to 'account' the 'collections' parameter will be ignored. When includeAllUserRecords or subject is set, this will be ignored.",
knownValues: ['account', 'record'],
},
},
Expand Down
19 changes: 19 additions & 0 deletions packages/ozone/src/lexicon/types/com/atproto/admin/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface AccountView {
emailConfirmedAt?: string
inviteNote?: string
deactivatedAt?: string
threatSignatures?: ThreatSignature[]
[k: string]: unknown
}

Expand Down Expand Up @@ -87,3 +88,21 @@ export function isRepoBlobRef(v: unknown): v is RepoBlobRef {
export function validateRepoBlobRef(v: unknown): ValidationResult {
return lexicons.validate('com.atproto.admin.defs#repoBlobRef', v)
}

export interface ThreatSignature {
property: string
value: string
[k: string]: unknown
}

export function isThreatSignature(v: unknown): v is ThreatSignature {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'com.atproto.admin.defs#threatSignature'
)
}

export function validateThreatSignature(v: unknown): ValidationResult {
return lexicons.validate('com.atproto.admin.defs#threatSignature', v)
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export interface QueryParams {
subject?: string
/** If specified, only events where the subject belongs to the given collections will be returned. When subjectType is set to 'account', this will be ignored. */
collections?: string[]
/** If specified, only events where the subject is of the given type (account or record) will be returned. When this is set to 'account' the 'collections' parameter will be ignored. */
/** If specified, only events where the subject is of the given type (account or record) will be returned. When this is set to 'account' the 'collections' parameter will be ignored. When includeAllUserRecords or subject is set, this will be ignored. */
subjectType?: 'account' | 'record' | (string & {})
/** If true, events on all record types (posts, lists, profile etc.) owned by the did are returned */
/** If true, events on all record types (posts, lists, profile etc.) or records from given 'collections' param, owned by the did are returned. */
includeAllUserRecords: boolean
limit: number
/** If true, only events with comments are returned */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
import * as ToolsOzoneModerationDefs from './defs'

export interface QueryParams {
/** All subjects belonging to the account specified in the 'subject' param will be returned. */
/** All subjects, or subjects from given 'collections' param, belonging to the account specified in the 'subject' param will be returned. */
includeAllUserRecords?: boolean
/** The subject to get the status for. */
subject?: string
Expand Down Expand Up @@ -45,7 +45,7 @@ export interface QueryParams {
cursor?: string
/** If specified, subjects belonging to the given collections will be returned. When subjectType is set to 'account', this will be ignored. */
collections?: string[]
/** If specified, subjects of the given type (account or record) will be returned. When this is set to 'account' the 'collections' parameter will be ignored. */
/** If specified, subjects of the given type (account or record) will be returned. When this is set to 'account' the 'collections' parameter will be ignored. When includeAllUserRecords or subject is set, this will be ignored. */
subjectType?: 'account' | 'record' | (string & {})
}

Expand Down
Loading

0 comments on commit 0158ab3

Please sign in to comment.