Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow filtering moderation queue by language #2161

Merged
merged 20 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lexicons/com/atproto/admin/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@
"suspendUntil": {
"type": "string",
"format": "datetime"
},
"tags": {
"type": "array",
"items": { "type": "string" }
}
}
},
Expand Down Expand Up @@ -587,6 +591,27 @@
}
}
},
"modEventTag": {
"type": "object",
"description": "Add/Remove a tag on a subject",
"required": ["add", "remove"],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do the arrays need to be required, or can they be omitted if empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to stay in line with the labelling lexicons where we require both create and negate properties. I don't think we allow defining required fields as "one or the other" which is probably why this is kinda needed?

"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."
}
}
},
"communicationTemplateView": {
"type": "object",
"required": [
Expand Down
3 changes: 2 additions & 1 deletion lexicons/com/atproto/admin/emitModerationEvent.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"com.atproto.admin.defs#modEventMute",
"com.atproto.admin.defs#modEventReverseTakedown",
"com.atproto.admin.defs#modEventUnmute",
"com.atproto.admin.defs#modEventEmail"
"com.atproto.admin.defs#modEventEmail",
"com.atproto.admin.defs#modEventTag"
]
},
"subject": {
Expand Down
10 changes: 10 additions & 0 deletions lexicons/com/atproto/admin/queryModerationEvents.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@
"items": { "type": "string" },
"description": "If specified, only events where all of these labels were removed are returned"
},
"addedTags": {
"type": "array",
"items": { "type": "string" },
"description": "If specified, only events where all of these tags were added are returned"
},
"removedTags": {
"type": "array",
"items": { "type": "string" },
"description": "If specified, only events where all of these tags were removed are returned"
},
"reportTypes": {
"type": "array",
"items": {
Expand Down
8 changes: 8 additions & 0 deletions lexicons/com/atproto/admin/queryModerationStatuses.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@
"maximum": 100,
"default": 50
},
"tags": {
"type": "array",
"items": { "type": "string" }
},
"excludeTags": {
"type": "array",
"items": { "type": "string" }
},
"cursor": { "type": "string" }
}
},
Expand Down
62 changes: 62 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@ export const schemaDict = {
type: 'string',
format: 'datetime',
},
tags: {
type: 'array',
items: {
type: 'string',
},
},
},
},
reportViewDetail: {
Expand Down Expand Up @@ -897,6 +903,33 @@ export const schemaDict = {
},
},
},
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.',
},
},
},
communicationTemplateView: {
type: 'object',
required: [
Expand Down Expand Up @@ -1075,6 +1108,7 @@ export const schemaDict = {
'lex:com.atproto.admin.defs#modEventReverseTakedown',
'lex:com.atproto.admin.defs#modEventUnmute',
'lex:com.atproto.admin.defs#modEventEmail',
'lex:com.atproto.admin.defs#modEventTag',
],
},
subject: {
Expand Down Expand Up @@ -1503,6 +1537,22 @@ export const schemaDict = {
description:
'If specified, only events where all of these labels were removed are returned',
},
addedTags: {
type: 'array',
items: {
type: 'string',
},
description:
'If specified, only events where all of these tags were added are returned',
},
removedTags: {
type: 'array',
items: {
type: 'string',
},
description:
'If specified, only events where all of these tags were removed are returned',
},
reportTypes: {
type: 'array',
items: {
Expand Down Expand Up @@ -1620,6 +1670,18 @@ export const schemaDict = {
maximum: 100,
default: 50,
},
tags: {
type: 'array',
items: {
type: 'string',
},
},
excludeTags: {
type: 'array',
items: {
type: 'string',
},
},
cursor: {
type: 'string',
},
Expand Down
24 changes: 24 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 @@ -156,6 +156,7 @@ export interface SubjectStatusView {
/** 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. */
appealed?: boolean
suspendUntil?: string
tags?: string[]
[k: string]: unknown
}

Expand Down Expand Up @@ -720,6 +721,29 @@ export function validateModEventEmail(v: unknown): ValidationResult {
return lexicons.validate('com.atproto.admin.defs#modEventEmail', v)
}

/** Add/Remove a tag on a subject */
export interface ModEventTag {
/** Tags to be added to the subject. If already exists, won't be duplicated. */
add: string[]
/** Tags to be removed to the subject. Ignores a tag If it doesn't exist, won't be duplicated. */
remove: string[]
/** Additional comment about added/removed tags. */
comment?: string
[k: string]: unknown
}

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

export function validateModEventTag(v: unknown): ValidationResult {
return lexicons.validate('com.atproto.admin.defs#modEventTag', v)
}

export interface CommunicationTemplateView {
id: string
/** Name of the template. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface InputSchema {
| ComAtprotoAdminDefs.ModEventReverseTakedown
| ComAtprotoAdminDefs.ModEventUnmute
| ComAtprotoAdminDefs.ModEventEmail
| ComAtprotoAdminDefs.ModEventTag
| { $type: string; [k: string]: unknown }
subject:
| ComAtprotoAdminDefs.RepoRef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export interface QueryParams {
addedLabels?: string[]
/** If specified, only events where all of these labels were removed are returned */
removedLabels?: string[]
/** If specified, only events where all of these tags were added are returned */
addedTags?: string[]
/** If specified, only events where all of these tags were removed are returned */
removedTags?: string[]
reportTypes?: string[]
cursor?: string
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export interface QueryParams {
/** Get subjects in unresolved appealed status */
appealed?: boolean
limit?: number
tags?: string[]
excludeTags?: string[]
cursor?: string
}

Expand Down
62 changes: 62 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@ export const schemaDict = {
type: 'string',
format: 'datetime',
},
tags: {
type: 'array',
items: {
type: 'string',
},
},
},
},
reportViewDetail: {
Expand Down Expand Up @@ -897,6 +903,33 @@ export const schemaDict = {
},
},
},
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.',
},
},
},
communicationTemplateView: {
type: 'object',
required: [
Expand Down Expand Up @@ -1075,6 +1108,7 @@ export const schemaDict = {
'lex:com.atproto.admin.defs#modEventReverseTakedown',
'lex:com.atproto.admin.defs#modEventUnmute',
'lex:com.atproto.admin.defs#modEventEmail',
'lex:com.atproto.admin.defs#modEventTag',
],
},
subject: {
Expand Down Expand Up @@ -1503,6 +1537,22 @@ export const schemaDict = {
description:
'If specified, only events where all of these labels were removed are returned',
},
addedTags: {
type: 'array',
items: {
type: 'string',
},
description:
'If specified, only events where all of these tags were added are returned',
},
removedTags: {
type: 'array',
items: {
type: 'string',
},
description:
'If specified, only events where all of these tags were removed are returned',
},
reportTypes: {
type: 'array',
items: {
Expand Down Expand Up @@ -1620,6 +1670,18 @@ export const schemaDict = {
maximum: 100,
default: 50,
},
tags: {
type: 'array',
items: {
type: 'string',
},
},
excludeTags: {
type: 'array',
items: {
type: 'string',
},
},
cursor: {
type: 'string',
},
Expand Down
24 changes: 24 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 @@ -156,6 +156,7 @@ export interface SubjectStatusView {
/** 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. */
appealed?: boolean
suspendUntil?: string
tags?: string[]
[k: string]: unknown
}

Expand Down Expand Up @@ -720,6 +721,29 @@ export function validateModEventEmail(v: unknown): ValidationResult {
return lexicons.validate('com.atproto.admin.defs#modEventEmail', v)
}

/** Add/Remove a tag on a subject */
export interface ModEventTag {
/** Tags to be added to the subject. If already exists, won't be duplicated. */
add: string[]
/** Tags to be removed to the subject. Ignores a tag If it doesn't exist, won't be duplicated. */
remove: string[]
/** Additional comment about added/removed tags. */
comment?: string
[k: string]: unknown
}

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

export function validateModEventTag(v: unknown): ValidationResult {
return lexicons.validate('com.atproto.admin.defs#modEventTag', v)
}

export interface CommunicationTemplateView {
id: string
/** Name of the template. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface InputSchema {
| ComAtprotoAdminDefs.ModEventReverseTakedown
| ComAtprotoAdminDefs.ModEventUnmute
| ComAtprotoAdminDefs.ModEventEmail
| ComAtprotoAdminDefs.ModEventTag
| { $type: string; [k: string]: unknown }
subject:
| ComAtprotoAdminDefs.RepoRef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export interface QueryParams {
addedLabels?: string[]
/** If specified, only events where all of these labels were removed are returned */
removedLabels?: string[]
/** If specified, only events where all of these tags were added are returned */
addedTags?: string[]
/** If specified, only events where all of these tags were removed are returned */
removedTags?: string[]
reportTypes?: string[]
cursor?: string
}
Expand Down
Loading
Loading