Skip to content

Commit

Permalink
Simplify PDS moderation (#1723)
Browse files Browse the repository at this point in the history
* spec out new simple pds mod routes

* introduce new admin state endpoints

* wire up routes

* clean up pds

* revoke refresh tokens

* getUserAccountInfo

* pr tidy

* fixing some tests

* fixing up more tests

* fanout takedowns to pds

* fanout admin reqs to pds

* tidy

* more tidy & add more pds moderation tests

* getUserAccountInfo -> getAccountInfo

* dont hydrate pds info on searchRepos

* fix build

* port admin tests to bsky package

* clean up old snaps

* tests on fanout

* tweak naming

* missed a rename

* tidy renames

* fix lex name

* tidy & move snap

* fix build

* cleanup repeat process all

* skip actor search test

* fix bday paradox

* tidy up pds service auth

* rm skipped test

* retry http

* tidy

* improve fanout error handling

* fix test

* return signing key in did-web

* more tests

* tidy serivce auth checks

* change takedownId col to takedownRef

* build branch

* fix bsky test

* add service key to indexer

* move signing key to api entry

* dont build
  • Loading branch information
dholms authored Oct 30, 2023
1 parent ec0dfdc commit fcb19c9
Show file tree
Hide file tree
Showing 117 changed files with 3,025 additions and 3,473 deletions.
40 changes: 40 additions & 0 deletions lexicons/com/atproto/admin/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
"lexicon": 1,
"id": "com.atproto.admin.defs",
"defs": {
"statusAttr": {
"type": "object",
"required": ["applied"],
"properties": {
"applied": { "type": "boolean" },
"ref": { "type": "string" }
}
},
"actionView": {
"type": "object",
"required": [
Expand Down Expand Up @@ -243,6 +251,29 @@
"inviteNote": { "type": "string" }
}
},
"accountView": {
"type": "object",
"required": ["did", "handle", "indexedAt"],
"properties": {
"did": { "type": "string", "format": "did" },
"handle": { "type": "string", "format": "handle" },
"email": { "type": "string" },
"indexedAt": { "type": "string", "format": "datetime" },
"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" }
}
},
"repoViewNotFound": {
"type": "object",
"required": ["did"],
Expand All @@ -257,6 +288,15 @@
"did": { "type": "string", "format": "did" }
}
},
"repoBlobRef": {
"type": "object",
"required": ["did", "cid"],
"properties": {
"did": { "type": "string", "format": "did" },
"cid": { "type": "string", "format": "cid" },
"recordUri": { "type": "string", "format": "at-uri" }
}
},
"recordView": {
"type": "object",
"required": [
Expand Down
24 changes: 24 additions & 0 deletions lexicons/com/atproto/admin/getAccountInfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"lexicon": 1,
"id": "com.atproto.admin.getAccountInfo",
"defs": {
"main": {
"type": "query",
"description": "View details about an account.",
"parameters": {
"type": "params",
"required": ["did"],
"properties": {
"did": { "type": "string", "format": "did" }
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "ref",
"ref": "com.atproto.admin.defs#accountView"
}
}
}
}
}
39 changes: 39 additions & 0 deletions lexicons/com/atproto/admin/getSubjectStatus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"lexicon": 1,
"id": "com.atproto.admin.getSubjectStatus",
"defs": {
"main": {
"type": "query",
"description": "Fetch the service-specific the admin status of a subject (account, record, or blob)",
"parameters": {
"type": "params",
"properties": {
"did": { "type": "string", "format": "did" },
"uri": { "type": "string", "format": "at-uri" },
"blob": { "type": "string", "format": "cid" }
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["subject"],
"properties": {
"subject": {
"type": "union",
"refs": [
"com.atproto.admin.defs#repoRef",
"com.atproto.repo.strongRef",
"com.atproto.admin.defs#repoBlobRef"
]
},
"takedown": {
"type": "ref",
"ref": "com.atproto.admin.defs#statusAttr"
}
}
}
}
}
}
}
1 change: 0 additions & 1 deletion lexicons/com/atproto/admin/searchRepos.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"description": "DEPRECATED: use 'q' instead"
},
"q": { "type": "string" },
"invitedBy": { "type": "string" },
"limit": {
"type": "integer",
"minimum": 1,
Expand Down
52 changes: 52 additions & 0 deletions lexicons/com/atproto/admin/updateSubjectStatus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"lexicon": 1,
"id": "com.atproto.admin.updateSubjectStatus",
"defs": {
"main": {
"type": "procedure",
"description": "Update the service-specific admin status of a subject (account, record, or blob)",
"input": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["subject"],
"properties": {
"subject": {
"type": "union",
"refs": [
"com.atproto.admin.defs#repoRef",
"com.atproto.repo.strongRef",
"com.atproto.admin.defs#repoBlobRef"
]
},
"takedown": {
"type": "ref",
"ref": "com.atproto.admin.defs#statusAttr"
}
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["subject"],
"properties": {
"subject": {
"type": "union",
"refs": [
"com.atproto.admin.defs#repoRef",
"com.atproto.repo.strongRef",
"com.atproto.admin.defs#repoBlobRef"
]
},
"takedown": {
"type": "ref",
"ref": "com.atproto.admin.defs#statusAttr"
}
}
}
}
}
}
}
39 changes: 39 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@ import * as ComAtprotoAdminDefs from './types/com/atproto/admin/defs'
import * as ComAtprotoAdminDisableAccountInvites from './types/com/atproto/admin/disableAccountInvites'
import * as ComAtprotoAdminDisableInviteCodes from './types/com/atproto/admin/disableInviteCodes'
import * as ComAtprotoAdminEnableAccountInvites from './types/com/atproto/admin/enableAccountInvites'
import * as ComAtprotoAdminGetAccountInfo from './types/com/atproto/admin/getAccountInfo'
import * as ComAtprotoAdminGetInviteCodes from './types/com/atproto/admin/getInviteCodes'
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'
import * as ComAtprotoAdminGetModerationReports from './types/com/atproto/admin/getModerationReports'
import * as ComAtprotoAdminGetRecord from './types/com/atproto/admin/getRecord'
import * as ComAtprotoAdminGetRepo from './types/com/atproto/admin/getRepo'
import * as ComAtprotoAdminGetSubjectStatus from './types/com/atproto/admin/getSubjectStatus'
import * as ComAtprotoAdminResolveModerationReports from './types/com/atproto/admin/resolveModerationReports'
import * as ComAtprotoAdminReverseModerationAction from './types/com/atproto/admin/reverseModerationAction'
import * as ComAtprotoAdminSearchRepos from './types/com/atproto/admin/searchRepos'
import * as ComAtprotoAdminSendEmail from './types/com/atproto/admin/sendEmail'
import * as ComAtprotoAdminTakeModerationAction from './types/com/atproto/admin/takeModerationAction'
import * as ComAtprotoAdminUpdateAccountEmail from './types/com/atproto/admin/updateAccountEmail'
import * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/updateAccountHandle'
import * as ComAtprotoAdminUpdateSubjectStatus from './types/com/atproto/admin/updateSubjectStatus'
import * as ComAtprotoIdentityResolveHandle from './types/com/atproto/identity/resolveHandle'
import * as ComAtprotoIdentityUpdateHandle from './types/com/atproto/identity/updateHandle'
import * as ComAtprotoLabelDefs from './types/com/atproto/label/defs'
Expand Down Expand Up @@ -145,20 +148,23 @@ export * as ComAtprotoAdminDefs from './types/com/atproto/admin/defs'
export * as ComAtprotoAdminDisableAccountInvites from './types/com/atproto/admin/disableAccountInvites'
export * as ComAtprotoAdminDisableInviteCodes from './types/com/atproto/admin/disableInviteCodes'
export * as ComAtprotoAdminEnableAccountInvites from './types/com/atproto/admin/enableAccountInvites'
export * as ComAtprotoAdminGetAccountInfo from './types/com/atproto/admin/getAccountInfo'
export * as ComAtprotoAdminGetInviteCodes from './types/com/atproto/admin/getInviteCodes'
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'
export * as ComAtprotoAdminGetModerationReports from './types/com/atproto/admin/getModerationReports'
export * as ComAtprotoAdminGetRecord from './types/com/atproto/admin/getRecord'
export * as ComAtprotoAdminGetRepo from './types/com/atproto/admin/getRepo'
export * as ComAtprotoAdminGetSubjectStatus from './types/com/atproto/admin/getSubjectStatus'
export * as ComAtprotoAdminResolveModerationReports from './types/com/atproto/admin/resolveModerationReports'
export * as ComAtprotoAdminReverseModerationAction from './types/com/atproto/admin/reverseModerationAction'
export * as ComAtprotoAdminSearchRepos from './types/com/atproto/admin/searchRepos'
export * as ComAtprotoAdminSendEmail from './types/com/atproto/admin/sendEmail'
export * as ComAtprotoAdminTakeModerationAction from './types/com/atproto/admin/takeModerationAction'
export * as ComAtprotoAdminUpdateAccountEmail from './types/com/atproto/admin/updateAccountEmail'
export * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/updateAccountHandle'
export * as ComAtprotoAdminUpdateSubjectStatus from './types/com/atproto/admin/updateSubjectStatus'
export * as ComAtprotoIdentityResolveHandle from './types/com/atproto/identity/resolveHandle'
export * as ComAtprotoIdentityUpdateHandle from './types/com/atproto/identity/updateHandle'
export * as ComAtprotoLabelDefs from './types/com/atproto/label/defs'
Expand Down Expand Up @@ -396,6 +402,17 @@ export class AdminNS {
})
}

getAccountInfo(
params?: ComAtprotoAdminGetAccountInfo.QueryParams,
opts?: ComAtprotoAdminGetAccountInfo.CallOptions,
): Promise<ComAtprotoAdminGetAccountInfo.Response> {
return this._service.xrpc
.call('com.atproto.admin.getAccountInfo', params, undefined, opts)
.catch((e) => {
throw ComAtprotoAdminGetAccountInfo.toKnownErr(e)
})
}

getInviteCodes(
params?: ComAtprotoAdminGetInviteCodes.QueryParams,
opts?: ComAtprotoAdminGetInviteCodes.CallOptions,
Expand Down Expand Up @@ -473,6 +490,17 @@ export class AdminNS {
})
}

getSubjectStatus(
params?: ComAtprotoAdminGetSubjectStatus.QueryParams,
opts?: ComAtprotoAdminGetSubjectStatus.CallOptions,
): Promise<ComAtprotoAdminGetSubjectStatus.Response> {
return this._service.xrpc
.call('com.atproto.admin.getSubjectStatus', params, undefined, opts)
.catch((e) => {
throw ComAtprotoAdminGetSubjectStatus.toKnownErr(e)
})
}

resolveModerationReports(
data?: ComAtprotoAdminResolveModerationReports.InputSchema,
opts?: ComAtprotoAdminResolveModerationReports.CallOptions,
Expand Down Expand Up @@ -549,6 +577,17 @@ export class AdminNS {
throw ComAtprotoAdminUpdateAccountHandle.toKnownErr(e)
})
}

updateSubjectStatus(
data?: ComAtprotoAdminUpdateSubjectStatus.InputSchema,
opts?: ComAtprotoAdminUpdateSubjectStatus.CallOptions,
): Promise<ComAtprotoAdminUpdateSubjectStatus.Response> {
return this._service.xrpc
.call('com.atproto.admin.updateSubjectStatus', opts?.qp, data, opts)
.catch((e) => {
throw ComAtprotoAdminUpdateSubjectStatus.toKnownErr(e)
})
}
}

export class IdentityNS {
Expand Down
Loading

0 comments on commit fcb19c9

Please sign in to comment.