-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
291 additions
and
908 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
packages/bsky/src/api/com/atproto/admin/getSubjectStatus.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { InvalidRequestError } from '@atproto/xrpc-server' | ||
import { Server } from '../../../../lexicon' | ||
import AppContext from '../../../../context' | ||
import { OutputSchema } from '../../../../lexicon/types/com/atproto/admin/getSubjectStatus' | ||
|
||
export default function (server: Server, ctx: AppContext) { | ||
server.com.atproto.admin.getSubjectStatus({ | ||
auth: ctx.roleVerifier, | ||
handler: async ({ params }) => { | ||
const { did, uri, blob } = params | ||
const modService = ctx.services.moderation(ctx.db.getPrimary()) | ||
let body: OutputSchema | null = null | ||
if (blob) { | ||
if (!did) { | ||
throw new InvalidRequestError( | ||
'Must provide a did to request blob state', | ||
) | ||
} | ||
const takedown = await modService.getBlobTakedownRef(did, blob) | ||
if (takedown) { | ||
body = { | ||
subject: { | ||
$type: 'com.atproto.admin.defs#repoBlobRef', | ||
did: did, | ||
cid: blob, | ||
}, | ||
takedown, | ||
} | ||
} | ||
} else if (uri) { | ||
const [takedown, cidRes] = await Promise.all([ | ||
modService.getRecordTakedownRef(uri), | ||
ctx.db | ||
.getPrimary() | ||
.db.selectFrom('record') | ||
.where('uri', '=', uri) | ||
.select('cid') | ||
.executeTakeFirst(), | ||
]) | ||
if (cidRes && takedown) { | ||
body = { | ||
subject: { | ||
$type: 'com.atproto.repo.strongRef', | ||
uri, | ||
cid: cidRes.cid, | ||
}, | ||
takedown, | ||
} | ||
} | ||
} else if (did) { | ||
const takedown = await modService.getRepoTakedownRef(did) | ||
if (takedown) { | ||
body = { | ||
subject: { | ||
$type: 'com.atproto.admin.defs#repoRef', | ||
did: did, | ||
}, | ||
takedown, | ||
} | ||
} | ||
} else { | ||
throw new InvalidRequestError('No provided subject') | ||
} | ||
if (body === null) { | ||
throw new InvalidRequestError('Subject not found', 'NotFound') | ||
} | ||
return { | ||
encoding: 'application/json', | ||
body, | ||
} | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 0 additions & 55 deletions
55
packages/bsky/tests/admin/__snapshots__/moderation.test.ts.snap
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.