[SDK] Remove @atproto/api (#11386)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Samuel Newman
2026-08-13 22:26:22 +03:00
committed by GitHub
parent 54da80dfb0
commit 9fe0084874
391 changed files with 3130 additions and 3589 deletions
+4 -5
View File
@@ -1,6 +1,5 @@
import {useState} from 'react'
import {View} from 'react-native'
import {type ComAtprotoLabelDefs, ToolsOzoneReportDefs} from '@atproto/api'
import {XrpcResponseError} from '@atproto/lex'
import {type AtUriString, type DidString} from '@atproto/syntax'
import {msg} from '@lingui/core/macro'
@@ -23,14 +22,14 @@ import {Loader} from '#/components/Loader'
import * as Toast from '#/components/Toast'
import {Text} from '#/components/Typography'
import {IS_ANDROID} from '#/env'
import {com} from '#/lexicons'
import {com, tools} from '#/lexicons'
export function AppealForm({
label,
control,
onPressBack,
}: {
label: ComAtprotoLabelDefs.Label
label: com.atproto.label.defs.Label
control: Dialog.DialogOuterProps['control']
onPressBack: () => void
}) {
@@ -51,7 +50,7 @@ export function AppealForm({
await client.call(
com.atproto.moderation.createReport,
{
reasonType: ToolsOzoneReportDefs.REASONAPPEAL,
reasonType: tools.ozone.report.defs.reasonAppeal.value,
/*
* `useLabelSubject` derives one shape or the other from the label's
* `cid`: an at-uri plus cid for a record, or the label's `uri` reused
@@ -70,7 +69,7 @@ export function AppealForm({
reason: details,
},
// the appeal goes to the labeler that applied the label
{service: `${label.src as DidString}#atproto_labeler`},
{service: `${label.src}#atproto_labeler`},
)
},
onError: err => {
+2 -3
View File
@@ -1,6 +1,5 @@
import {useState} from 'react'
import {View} from 'react-native'
import {type ChatBskyConvoDefs} from '@atproto/api'
import {Trans, useLingui} from '@lingui/react/macro'
import {useQueryClient} from '@tanstack/react-query'
@@ -27,7 +26,7 @@ import {Text} from '#/components/Typography'
import {chat} from '#/lexicons'
import {type AnyProfileView} from '#/types/bsky/profile'
type Item = ChatBskyConvoDefs.ConvoView
type Item = chat.bsky.convo.defs.ConvoView
type BlockDialogProps = {
control: DialogControlProps
@@ -252,7 +251,7 @@ function MutualGroupChat({
onOptimisticallyRemoveConvo,
onRestoreConvo,
}: {
view: ChatBskyConvoDefs.ConvoView
view: chat.bsky.convo.defs.ConvoView
profileDid: string
currentConvoId?: string
onOptimisticallyRemoveConvo: (convoId: string) => void
+2 -2
View File
@@ -1,5 +1,4 @@
import {type StyleProp, View, type ViewStyle} from 'react-native'
import {type ComAtprotoLabelDefs} from '@atproto/api'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
import {Plural} from '@lingui/react/macro'
@@ -18,13 +17,14 @@ import {
LabelsOnMeDialog,
useLabelsOnMeDialogControl,
} from '#/components/moderation/LabelsOnMeDialog'
import {type com} from '#/lexicons'
export function LabelsOnMe({
labels,
size,
style,
}: {
labels: ComAtprotoLabelDefs.Label[] | undefined
labels: com.atproto.label.defs.Label[] | undefined
size?: ButtonSize
style?: StyleProp<ViewStyle>
}) {
@@ -1,6 +1,5 @@
import {useMemo, useState} from 'react'
import {View} from 'react-native'
import {type ComAtprotoLabelDefs} from '@atproto/api'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro'
@@ -17,13 +16,14 @@ import * as Dialog from '#/components/Dialog'
import {InlineLinkText} from '#/components/Link'
import {AppealForm} from '#/components/moderation/AppealForm'
import {Text} from '#/components/Typography'
import {type com} from '#/lexicons'
import {Divider} from '../Divider'
export {useDialogControl as useLabelsOnMeDialogControl} from '#/components/Dialog'
export interface LabelsOnMeDialogProps {
control: Dialog.DialogOuterProps['control']
labels: ComAtprotoLabelDefs.Label[]
labels: com.atproto.label.defs.Label[]
/**
* Whether the labels are being shown on the user's account or on a post.
* With `content`, the list may include account-level labels, which get a
@@ -47,7 +47,7 @@ function LabelsOnMeDialogInner(props: LabelsOnMeDialogProps) {
const {_} = useLingui()
const {currentAccount} = useSession()
const [appealingLabel, setAppealingLabel] = useState<
ComAtprotoLabelDefs.Label | undefined
com.atproto.label.defs.Label | undefined
>(undefined)
const {labels} = props
const isAccount = props.type === 'account'
@@ -118,7 +118,7 @@ function Label({
control,
onPressAppeal,
}: {
label: ComAtprotoLabelDefs.Label
label: com.atproto.label.defs.Label
isSelfLabel: boolean
/**
* Call out that the label applies to the whole account, for contexts that
@@ -126,7 +126,7 @@ function Label({
*/
showAccountCallout?: boolean
control: Dialog.DialogOuterProps['control']
onPressAppeal: (label: ComAtprotoLabelDefs.Label) => void
onPressAppeal: (label: com.atproto.label.defs.Label) => void
}) {
const t = useTheme()
const {_} = useLingui()
+4 -4
View File
@@ -1,5 +1,4 @@
import {type StyleProp, View, type ViewStyle} from 'react-native'
import {type AppBskyFeedDefs, type ComAtprotoLabelDefs} from '@atproto/api'
import {type ModerationCause, type ModerationUI} from '@bsky.app/sdk/moderation'
import {plural} from '@lingui/core/macro'
import {useLingui} from '@lingui/react/macro'
@@ -16,6 +15,7 @@ import {
useLabelsOnMeDialogControl,
} from '#/components/moderation/LabelsOnMeDialog'
import * as Pills from '#/components/Pills'
import {type app, type com} from '#/lexicons'
export function PostAlerts({
post,
@@ -24,7 +24,7 @@ export function PostAlerts({
style,
additionalCauses,
}: {
post?: AppBskyFeedDefs.PostView
post?: app.bsky.feed.defs.PostView
modui: ModerationUI
/**
* Expanded views (e.g. the thread anchor post) render larger pills and
@@ -48,7 +48,7 @@ export function PostAlerts({
* author's only entry point to appeal labels on their content.
*/
const isOwnPost = !!post && post.author.did === currentAccount?.did
const allLabels: ComAtprotoLabelDefs.Label[] =
const allLabels: com.atproto.label.defs.Label[] =
isOwnPost && view === 'expanded'
? [
...(post.labels ?? []),
@@ -134,7 +134,7 @@ function AdditionalLabels({
size,
hasPrecedingPills,
}: {
labels: ComAtprotoLabelDefs.Label[]
labels: com.atproto.label.defs.Label[]
size?: Pills.CommonProps['size']
/**
* The compact "+n" syntax only makes sense as a continuation of other
+2 -2
View File
@@ -7,7 +7,6 @@ import {
View,
type ViewStyle,
} from 'react-native'
import {type AppBskyActorDefs} from '@atproto/api'
import {type ModerationCause, type ModerationUI} from '@bsky.app/sdk/moderation'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
@@ -25,13 +24,14 @@ import {
useModerationDetailsDialogControl,
} from '#/components/moderation/ModerationDetailsDialog'
import {Text} from '#/components/Typography'
import {type app} from '#/lexicons'
interface Props extends React.ComponentProps<typeof Link> {
disabled: boolean
iconSize: number
iconStyles: StyleProp<ViewStyle>
modui: ModerationUI
profile: AppBskyActorDefs.ProfileViewBasic
profile: app.bsky.actor.defs.ProfileViewBasic
interpretFilterAsBlur?: boolean
hiderStyle?: StyleProp<ViewStyle>
}
@@ -1,5 +1,5 @@
import {BSKY_LABELER_DID} from '@atproto/api'
import {type AtUriString, type DidString} from '@atproto/syntax'
import {api} from '@bsky.app/sdk'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
import {useMutation} from '@tanstack/react-query'
@@ -121,7 +121,7 @@ export function useSubmitReportMutation() {
state.includeVideoTimestamp &&
videoTimestampSeconds != null &&
subject.type === 'post' &&
labeler.creator.did === BSKY_LABELER_DID
labeler.creator.did === api.moderation.did
? {videoTimestampSeconds}
: undefined
+125 -73
View File
@@ -1,11 +1,8 @@
import {applicationId} from 'expo-application'
import {
ComAtprotoModerationDefs as RootReportDefs,
ToolsOzoneReportDefs as OzoneReportDefs,
} from '@atproto/api'
import {type ParsedReportSubject} from '#/components/moderation/ReportDialog/types'
import {IS_ANDROID, IS_IOS, IS_WEB} from '#/env'
import {com, tools} from '#/lexicons'
export const DMCA_LINK = 'https://bsky.social/about/support/copyright'
export const SUPPORT_PAGE = 'https://bsky.social/about/support'
@@ -31,59 +28,96 @@ export const NEW_TO_OLD_REASON_MAPPING: Record<string, string> = {}
* @see https://github.com/bluesky-social/atproto/blob/4c15fb47cec26060bff2e710e95869a90c9d7fdd/packages/ozone/src/mod-service/profile.ts#L16-L64
*/
export const NEW_TO_OLD_REASONS_MAP: Record<
OzoneReportDefs.ReasonType,
RootReportDefs.ReasonType
tools.ozone.report.defs.ReasonType,
com.atproto.moderation.defs.ReasonType
> = {
[OzoneReportDefs.REASONAPPEAL]: RootReportDefs.REASONAPPEAL,
[OzoneReportDefs.REASONOTHER]: RootReportDefs.REASONOTHER,
[tools.ozone.report.defs.reasonAppeal.value]:
com.atproto.moderation.defs.reasonAppeal.value,
[tools.ozone.report.defs.reasonOther.value]:
com.atproto.moderation.defs.reasonOther.value,
[OzoneReportDefs.REASONVIOLENCEANIMAL]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONVIOLENCETHREATS]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONVIOLENCEGRAPHICCONTENT]:
RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONVIOLENCEGLORIFICATION]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONVIOLENCEEXTREMISTCONTENT]:
RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONVIOLENCETRAFFICKING]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONVIOLENCEOTHER]: RootReportDefs.REASONVIOLATION,
[tools.ozone.report.defs.reasonViolenceAnimal.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonViolenceThreats.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonViolenceGraphicContent.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonViolenceGlorification.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonViolenceExtremistContent.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonViolenceTrafficking.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonViolenceOther.value]:
com.atproto.moderation.defs.reasonViolation.value,
[OzoneReportDefs.REASONSEXUALABUSECONTENT]: RootReportDefs.REASONSEXUAL,
[OzoneReportDefs.REASONSEXUALNCII]: RootReportDefs.REASONSEXUAL,
[OzoneReportDefs.REASONSEXUALDEEPFAKE]: RootReportDefs.REASONSEXUAL,
[OzoneReportDefs.REASONSEXUALANIMAL]: RootReportDefs.REASONSEXUAL,
[OzoneReportDefs.REASONSEXUALUNLABELED]: RootReportDefs.REASONSEXUAL,
[OzoneReportDefs.REASONSEXUALOTHER]: RootReportDefs.REASONSEXUAL,
[tools.ozone.report.defs.reasonSexualAbuseContent.value]:
com.atproto.moderation.defs.reasonSexual.value,
[tools.ozone.report.defs.reasonSexualNCII.value]:
com.atproto.moderation.defs.reasonSexual.value,
[tools.ozone.report.defs.reasonSexualDeepfake.value]:
com.atproto.moderation.defs.reasonSexual.value,
[tools.ozone.report.defs.reasonSexualAnimal.value]:
com.atproto.moderation.defs.reasonSexual.value,
[tools.ozone.report.defs.reasonSexualUnlabeled.value]:
com.atproto.moderation.defs.reasonSexual.value,
[tools.ozone.report.defs.reasonSexualOther.value]:
com.atproto.moderation.defs.reasonSexual.value,
[OzoneReportDefs.REASONCHILDSAFETYCSAM]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONCHILDSAFETYGROOM]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONCHILDSAFETYPRIVACY]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONCHILDSAFETYHARASSMENT]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONCHILDSAFETYOTHER]: RootReportDefs.REASONVIOLATION,
[tools.ozone.report.defs.reasonChildSafetyCSAM.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonChildSafetyGroom.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonChildSafetyPrivacy.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonChildSafetyHarassment.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonChildSafetyOther.value]:
com.atproto.moderation.defs.reasonViolation.value,
[OzoneReportDefs.REASONHARASSMENTTROLL]: RootReportDefs.REASONRUDE,
[OzoneReportDefs.REASONHARASSMENTTARGETED]: RootReportDefs.REASONRUDE,
[OzoneReportDefs.REASONHARASSMENTHATESPEECH]: RootReportDefs.REASONRUDE,
[OzoneReportDefs.REASONHARASSMENTDOXXING]: RootReportDefs.REASONRUDE,
[OzoneReportDefs.REASONHARASSMENTOTHER]: RootReportDefs.REASONRUDE,
[tools.ozone.report.defs.reasonHarassmentTroll.value]:
com.atproto.moderation.defs.reasonRude.value,
[tools.ozone.report.defs.reasonHarassmentTargeted.value]:
com.atproto.moderation.defs.reasonRude.value,
[tools.ozone.report.defs.reasonHarassmentHateSpeech.value]:
com.atproto.moderation.defs.reasonRude.value,
[tools.ozone.report.defs.reasonHarassmentDoxxing.value]:
com.atproto.moderation.defs.reasonRude.value,
[tools.ozone.report.defs.reasonHarassmentOther.value]:
com.atproto.moderation.defs.reasonRude.value,
[OzoneReportDefs.REASONMISLEADINGBOT]: RootReportDefs.REASONMISLEADING,
[OzoneReportDefs.REASONMISLEADINGIMPERSONATION]:
RootReportDefs.REASONMISLEADING,
[OzoneReportDefs.REASONMISLEADINGSPAM]: RootReportDefs.REASONSPAM,
[OzoneReportDefs.REASONMISLEADINGSCAM]: RootReportDefs.REASONMISLEADING,
[OzoneReportDefs.REASONMISLEADINGELECTIONS]: RootReportDefs.REASONMISLEADING,
[OzoneReportDefs.REASONMISLEADINGOTHER]: RootReportDefs.REASONMISLEADING,
[tools.ozone.report.defs.reasonMisleadingBot.value]:
com.atproto.moderation.defs.reasonMisleading.value,
[tools.ozone.report.defs.reasonMisleadingImpersonation.value]:
com.atproto.moderation.defs.reasonMisleading.value,
[tools.ozone.report.defs.reasonMisleadingSpam.value]:
com.atproto.moderation.defs.reasonSpam.value,
[tools.ozone.report.defs.reasonMisleadingScam.value]:
com.atproto.moderation.defs.reasonMisleading.value,
[tools.ozone.report.defs.reasonMisleadingElections.value]:
com.atproto.moderation.defs.reasonMisleading.value,
[tools.ozone.report.defs.reasonMisleadingOther.value]:
com.atproto.moderation.defs.reasonMisleading.value,
[OzoneReportDefs.REASONRULESITESECURITY]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONRULEPROHIBITEDSALES]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONRULEBANEVASION]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONRULEOTHER]: RootReportDefs.REASONVIOLATION,
[tools.ozone.report.defs.reasonRuleSiteSecurity.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonRuleProhibitedSales.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonRuleBanEvasion.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonRuleOther.value]:
com.atproto.moderation.defs.reasonViolation.value,
[OzoneReportDefs.REASONSELFHARMCONTENT]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONSELFHARMED]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONSELFHARMSTUNTS]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONSELFHARMSUBSTANCES]: RootReportDefs.REASONVIOLATION,
[OzoneReportDefs.REASONSELFHARMOTHER]: RootReportDefs.REASONVIOLATION,
[tools.ozone.report.defs.reasonSelfHarmContent.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonSelfHarmED.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonSelfHarmStunts.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonSelfHarmSubstances.value]:
com.atproto.moderation.defs.reasonViolation.value,
[tools.ozone.report.defs.reasonSelfHarmOther.value]:
com.atproto.moderation.defs.reasonViolation.value,
}
/**
@@ -91,42 +125,60 @@ export const NEW_TO_OLD_REASONS_MAP: Record<
* @see https://github.com/bluesky-social/proposals/tree/main/0009-mod-report-granularity#backwards-compatibility
*/
export const OLD_TO_NEW_REASONS_MAP: Record<
Exclude<RootReportDefs.ReasonType, OzoneReportDefs.ReasonType>,
OzoneReportDefs.ReasonType
Exclude<
com.atproto.moderation.defs.ReasonType,
tools.ozone.report.defs.ReasonType
>,
tools.ozone.report.defs.ReasonType
> = {
[RootReportDefs.REASONSPAM]: [OzoneReportDefs.REASONMISLEADINGSPAM],
[RootReportDefs.REASONVIOLATION]: [OzoneReportDefs.REASONRULEOTHER],
[RootReportDefs.REASONMISLEADING]: [OzoneReportDefs.REASONMISLEADINGOTHER],
[RootReportDefs.REASONSEXUAL]: [OzoneReportDefs.REASONSEXUALUNLABELED],
[RootReportDefs.REASONRUDE]: [OzoneReportDefs.REASONHARASSMENTOTHER],
[RootReportDefs.REASONOTHER]: [OzoneReportDefs.REASONOTHER],
[RootReportDefs.REASONAPPEAL]: [OzoneReportDefs.REASONAPPEAL],
[com.atproto.moderation.defs.reasonSpam.value]: [
tools.ozone.report.defs.reasonMisleadingSpam.value,
],
[com.atproto.moderation.defs.reasonViolation.value]: [
tools.ozone.report.defs.reasonRuleOther.value,
],
[com.atproto.moderation.defs.reasonMisleading.value]: [
tools.ozone.report.defs.reasonMisleadingOther.value,
],
[com.atproto.moderation.defs.reasonSexual.value]: [
tools.ozone.report.defs.reasonSexualUnlabeled.value,
],
[com.atproto.moderation.defs.reasonRude.value]: [
tools.ozone.report.defs.reasonHarassmentOther.value,
],
[com.atproto.moderation.defs.reasonOther.value]: [
tools.ozone.report.defs.reasonOther.value,
],
[com.atproto.moderation.defs.reasonAppeal.value]: [
tools.ozone.report.defs.reasonAppeal.value,
],
}
/**
* Set of report reasons that should optionally include additional details from
* the reporter.
*/
export const OTHER_REPORT_REASONS: Set<OzoneReportDefs.ReasonType> = new Set([
OzoneReportDefs.REASONVIOLENCEOTHER,
OzoneReportDefs.REASONSEXUALOTHER,
OzoneReportDefs.REASONCHILDSAFETYOTHER,
OzoneReportDefs.REASONHARASSMENTOTHER,
OzoneReportDefs.REASONMISLEADINGOTHER,
OzoneReportDefs.REASONRULEOTHER,
OzoneReportDefs.REASONSELFHARMOTHER,
OzoneReportDefs.REASONOTHER,
])
export const OTHER_REPORT_REASONS: Set<tools.ozone.report.defs.ReasonType> =
new Set([
tools.ozone.report.defs.reasonViolenceOther.value,
tools.ozone.report.defs.reasonSexualOther.value,
tools.ozone.report.defs.reasonChildSafetyOther.value,
tools.ozone.report.defs.reasonHarassmentOther.value,
tools.ozone.report.defs.reasonMisleadingOther.value,
tools.ozone.report.defs.reasonRuleOther.value,
tools.ozone.report.defs.reasonSelfHarmOther.value,
tools.ozone.report.defs.reasonOther.value,
])
/**
* Set of report reasons that should only be sent to Bluesky's moderation service.
*/
export const BSKY_LABELER_ONLY_REPORT_REASONS: Set<OzoneReportDefs.ReasonType> =
export const BSKY_LABELER_ONLY_REPORT_REASONS: Set<tools.ozone.report.defs.ReasonType> =
new Set([
OzoneReportDefs.REASONCHILDSAFETYCSAM,
OzoneReportDefs.REASONCHILDSAFETYGROOM,
OzoneReportDefs.REASONCHILDSAFETYOTHER,
OzoneReportDefs.REASONVIOLENCEEXTREMISTCONTENT,
tools.ozone.report.defs.reasonChildSafetyCSAM.value,
tools.ozone.report.defs.reasonChildSafetyGroom.value,
tools.ozone.report.defs.reasonChildSafetyOther.value,
tools.ozone.report.defs.reasonViolenceExtremistContent.value,
])
/**
@@ -1,11 +1,24 @@
import {XRPCError} from '@atproto/api'
import {XrpcResponseError} from '@atproto/lex'
import {com} from '#/lexicons'
import {classifyReportError} from './errors'
/**
* An error as the lex client builds one from a JSON error response body. The
* classifier only reads `error`, `message` and `status` back off it.
*/
function xrpcError(status: number, error: string, message: string) {
return new XrpcResponseError(
com.atproto.moderation.createReport.main,
new Response(null, {status}),
{encoding: 'application/json', body: {error, message}},
)
}
describe('classifyReportError', () => {
it('treats account takedown as an expected rejection', () => {
const result = classifyReportError(
new XRPCError(
xrpcError(
403,
'AccountTakedown',
'Report not accepted from takendown account',
@@ -27,7 +40,7 @@ describe('classifyReportError', () => {
it.each([
{
error: new XRPCError(
error: xrpcError(
502,
'InternalServerError',
'Failed to perform upstream request',
@@ -35,11 +48,11 @@ describe('classifyReportError', () => {
bucket: 'upstream-fetch',
},
{
error: new XRPCError(502, 'UpstreamFailure', 'Internal Server Error'),
error: xrpcError(502, 'UpstreamFailure', 'Internal Server Error'),
bucket: 'upstream-internal',
},
{
error: new XRPCError(
error: xrpcError(
502,
'UpstreamFailure',
'Upstream server responded with a 502 error',
@@ -47,7 +60,7 @@ describe('classifyReportError', () => {
bucket: 'upstream-http-502',
},
{
error: new XRPCError(
error: xrpcError(
504,
'UpstreamTimeout',
'Upstream server responded with a 504 error',
@@ -64,7 +77,7 @@ describe('classifyReportError', () => {
it('classifies an invalid reason type separately', () => {
const result = classifyReportError(
new XRPCError(
xrpcError(
400,
'InvalidRequest',
'Invalid reason type: tools.ozone.report.defs#reasonOther',
@@ -82,7 +95,7 @@ describe('classifyReportError', () => {
'separates a non-retryable upstream %i without calling it temporary',
status => {
const result = classifyReportError(
new XRPCError(
xrpcError(
502,
'UpstreamFailure',
`Upstream server responded with a ${status} error`,
@@ -1,4 +1,4 @@
import {XRPCError} from '@atproto/api'
import {XrpcResponseError} from '@atproto/lex'
import {isRetryableHttpStatus, shouldRetryError} from '#/lib/strings/errors'
@@ -16,7 +16,7 @@ export type ReportErrorClassification = {
}
export function classifyReportError(error: unknown): ReportErrorClassification {
if (!(error instanceof XRPCError)) {
if (!(error instanceof XrpcResponseError)) {
return classification('unexpected', 'unexpected', true)
}
@@ -7,7 +7,7 @@ import {
useState,
} from 'react'
import {Pressable, type ScrollView, View} from 'react-native'
import {BSKY_LABELER_DID} from '@atproto/api'
import {api} from '@bsky.app/sdk'
import {Trans, useLingui} from '@lingui/react/macro'
import {wait} from '#/lib/async/wait'
@@ -223,7 +223,7 @@ function Inner(
.filter(l => {
if (!state.selectedOption) return false
if (isBskyOnlyReason || isBskyOnlySubject) {
return l.creator.did === BSKY_LABELER_DID
return l.creator.did === api.moderation.did
}
const supportedReasonTypes: string[] | undefined = l.reasonTypes
if (supportedReasonTypes === undefined) return true
@@ -644,7 +644,7 @@ function Inner(
</View>
{videoTimestampSeconds !== undefined &&
state.selectedLabeler?.creator.did === BSKY_LABELER_DID && (
state.selectedLabeler?.creator.did === api.moderation.did && (
<IncludeVideoTimestampToggle
seconds={videoTimestampSeconds}
selected={state.includeVideoTimestamp}
@@ -1,6 +1,4 @@
import {ToolsOzoneReportDefs as OzoneReportDefs} from '@atproto/api'
import {type app} from '#/lexicons'
import {type app, tools} from '#/lexicons'
import {
getNciiQualificationOutcome,
initialState,
@@ -10,12 +8,12 @@ import {
const nciiOption = {
title: 'Non-consensual intimate imagery',
reason: OzoneReportDefs.REASONSEXUALNCII,
reason: tools.ozone.report.defs.reasonSexualNCII.value,
}
const otherOption = {
title: 'Unlabeled adult content',
reason: OzoneReportDefs.REASONSEXUALUNLABELED,
reason: tools.ozone.report.defs.reasonSexualUnlabeled.value,
}
function selectNciiOption(state: ReportState = initialState) {
@@ -1,11 +1,9 @@
import {ToolsOzoneReportDefs as OzoneReportDefs} from '@atproto/api'
import {OTHER_REPORT_REASONS} from '#/components/moderation/ReportDialog/const'
import {
type ReportCategoryConfig,
type ReportOption,
} from '#/components/moderation/ReportDialog/utils/useReportOptions'
import {type app} from '#/lexicons'
import {type app, tools} from '#/lexicons'
export type NciiQualification = {
isDepicted?: boolean
@@ -125,7 +123,8 @@ export function reducer(state: ReportState, action: ReportAction): ReportState {
includeVideoTimestamp: false,
}
case 'selectOption': {
const isNcii = action.option.reason === OzoneReportDefs.REASONSEXUALNCII
const isNcii =
action.option.reason === tools.ozone.report.defs.reasonSexualNCII.value
return {
...state,
selectedOption: action.option,
+11 -16
View File
@@ -1,17 +1,12 @@
import {
type $Typed,
type AppBskyActorDefs,
type AppBskyFeedDefs,
type AppBskyGraphDefs,
type ChatBskyConvoDefs,
} from '@atproto/api'
import {type $Typed} from '@atproto/lex'
import type * as Dialog from '#/components/Dialog'
import {type app, type chat} from '#/lexicons'
export type ReportSubjectConvoMessage = {
view: 'convo' | 'message'
convoId: string
message: ChatBskyConvoDefs.MessageView
message: chat.bsky.convo.defs.MessageView
}
export type ReportSubjectConvo = {
@@ -20,14 +15,14 @@ export type ReportSubjectConvo = {
}
export type ReportSubject =
| $Typed<AppBskyActorDefs.ProfileViewBasic>
| $Typed<AppBskyActorDefs.ProfileView>
| $Typed<AppBskyActorDefs.ProfileViewDetailed>
| $Typed<AppBskyActorDefs.StatusView>
| $Typed<AppBskyGraphDefs.ListView>
| $Typed<AppBskyFeedDefs.GeneratorView>
| $Typed<AppBskyGraphDefs.StarterPackView>
| $Typed<AppBskyFeedDefs.PostView>
| $Typed<app.bsky.actor.defs.ProfileViewBasic>
| $Typed<app.bsky.actor.defs.ProfileView>
| $Typed<app.bsky.actor.defs.ProfileViewDetailed>
| $Typed<app.bsky.actor.defs.StatusView>
| $Typed<app.bsky.graph.defs.ListView>
| $Typed<app.bsky.feed.defs.GeneratorView>
| $Typed<app.bsky.graph.defs.StarterPackView>
| $Typed<app.bsky.feed.defs.PostView>
| ReportSubjectConvoMessage
| ReportSubjectConvo
@@ -1,14 +1,8 @@
import {
AppBskyActorDefs,
AppBskyFeedDefs,
AppBskyFeedPost,
AppBskyGraphDefs,
} from '@atproto/api'
import {
type ParsedReportSubject,
type ReportSubject,
} from '#/components/moderation/ReportDialog/types'
import {app} from '#/lexicons'
import * as bsky from '#/types/bsky'
export function parseReportSubject(
@@ -31,16 +25,16 @@ export function parseReportSubject(
}
if (
AppBskyActorDefs.isProfileViewBasic(subject) ||
AppBskyActorDefs.isProfileView(subject) ||
AppBskyActorDefs.isProfileViewDetailed(subject)
bsky.isType(app.bsky.actor.defs.profileViewBasic, subject) ||
bsky.isType(app.bsky.actor.defs.profileView, subject) ||
bsky.isType(app.bsky.actor.defs.profileViewDetailed, subject)
) {
return {
type: 'account',
did: subject.did,
nsid: 'app.bsky.actor.profile',
}
} else if (AppBskyActorDefs.isStatusView(subject)) {
} else if (bsky.isType(app.bsky.actor.defs.statusView, subject)) {
if (!subject.uri || !subject.cid) return
return {
type: 'status',
@@ -48,36 +42,31 @@ export function parseReportSubject(
cid: subject.cid,
nsid: 'app.bsky.actor.status',
}
} else if (AppBskyGraphDefs.isListView(subject)) {
} else if (bsky.isType(app.bsky.graph.defs.listView, subject)) {
return {
type: 'list',
uri: subject.uri,
cid: subject.cid,
nsid: 'app.bsky.graph.list',
}
} else if (AppBskyFeedDefs.isGeneratorView(subject)) {
} else if (bsky.isType(app.bsky.feed.defs.generatorView, subject)) {
return {
type: 'feed',
uri: subject.uri,
cid: subject.cid,
nsid: 'app.bsky.feed.generator',
}
} else if (AppBskyGraphDefs.isStarterPackView(subject)) {
} else if (bsky.isType(app.bsky.graph.defs.starterPackView, subject)) {
return {
type: 'starterPack',
uri: subject.uri,
cid: subject.cid,
nsid: 'app.bsky.graph.starterPack',
}
} else if (AppBskyFeedDefs.isPostView(subject)) {
} else if (bsky.isType(app.bsky.feed.defs.postView, subject)) {
const record = subject.record
const embed = bsky.post.parseEmbed(subject.embed)
if (
bsky.dangerousIsType<AppBskyFeedPost.Record>(
record,
AppBskyFeedPost.isRecord,
)
) {
if (bsky.isType(app.bsky.feed.post, record)) {
return {
type: 'post',
uri: subject.uri,
@@ -1,8 +1,9 @@
import {useMemo} from 'react'
import {ToolsOzoneReportDefs as OzoneReportDefs} from '@atproto/api'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
import {tools} from '#/lexicons'
export type ReportCategory =
| 'childSafety'
| 'violencePhysicalHarm'
@@ -22,7 +23,7 @@ export type ReportCategoryConfig = {
export type ReportOption = {
title: string
reason: OzoneReportDefs.ReasonType
reason: tools.ozone.report.defs.ReasonType
}
export function useReportOptions() {
@@ -37,27 +38,27 @@ export function useReportOptions() {
options: [
{
title: _(msg`Spam`),
reason: OzoneReportDefs.REASONMISLEADINGSPAM,
reason: tools.ozone.report.defs.reasonMisleadingSpam.value,
},
{
title: _(msg`Scam`),
reason: OzoneReportDefs.REASONMISLEADINGSCAM,
reason: tools.ozone.report.defs.reasonMisleadingScam.value,
},
{
title: _(msg`Fake account or bot`),
reason: OzoneReportDefs.REASONMISLEADINGBOT,
reason: tools.ozone.report.defs.reasonMisleadingBot.value,
},
{
title: _(msg`Impersonation`),
reason: OzoneReportDefs.REASONMISLEADINGIMPERSONATION,
reason: tools.ozone.report.defs.reasonMisleadingImpersonation.value,
},
{
title: _(msg`False information about elections`),
reason: OzoneReportDefs.REASONMISLEADINGELECTIONS,
reason: tools.ozone.report.defs.reasonMisleadingElections.value,
},
{
title: _(msg`Other misleading content`),
reason: OzoneReportDefs.REASONMISLEADINGOTHER,
reason: tools.ozone.report.defs.reasonMisleadingOther.value,
},
],
},
@@ -70,27 +71,27 @@ export function useReportOptions() {
options: [
{
title: _(msg`Unlabeled adult content`),
reason: OzoneReportDefs.REASONSEXUALUNLABELED,
reason: tools.ozone.report.defs.reasonSexualUnlabeled.value,
},
{
title: _(msg`Adult sexual abuse content`),
reason: OzoneReportDefs.REASONSEXUALABUSECONTENT,
reason: tools.ozone.report.defs.reasonSexualAbuseContent.value,
},
{
title: _(msg`Non-consensual intimate imagery`),
reason: OzoneReportDefs.REASONSEXUALNCII,
reason: tools.ozone.report.defs.reasonSexualNCII.value,
},
{
title: _(msg`Deepfake adult content`),
reason: OzoneReportDefs.REASONSEXUALDEEPFAKE,
reason: tools.ozone.report.defs.reasonSexualDeepfake.value,
},
{
title: _(msg`Animal sexual abuse`),
reason: OzoneReportDefs.REASONSEXUALANIMAL,
reason: tools.ozone.report.defs.reasonSexualAnimal.value,
},
{
title: _(msg`Other sexual violence content`),
reason: OzoneReportDefs.REASONSEXUALOTHER,
reason: tools.ozone.report.defs.reasonSexualOther.value,
},
],
},
@@ -101,23 +102,23 @@ export function useReportOptions() {
options: [
{
title: _(msg`Trolling`),
reason: OzoneReportDefs.REASONHARASSMENTTROLL,
reason: tools.ozone.report.defs.reasonHarassmentTroll.value,
},
{
title: _(msg`Targeted harassment`),
reason: OzoneReportDefs.REASONHARASSMENTTARGETED,
reason: tools.ozone.report.defs.reasonHarassmentTargeted.value,
},
{
title: _(msg`Hate speech`),
reason: OzoneReportDefs.REASONHARASSMENTHATESPEECH,
reason: tools.ozone.report.defs.reasonHarassmentHateSpeech.value,
},
{
title: _(msg`Doxxing`),
reason: OzoneReportDefs.REASONHARASSMENTDOXXING,
reason: tools.ozone.report.defs.reasonHarassmentDoxxing.value,
},
{
title: _(msg`Other harassing or hateful content`),
reason: OzoneReportDefs.REASONHARASSMENTOTHER,
reason: tools.ozone.report.defs.reasonHarassmentOther.value,
},
],
},
@@ -128,31 +129,32 @@ export function useReportOptions() {
options: [
{
title: _(msg`Animal welfare`),
reason: OzoneReportDefs.REASONVIOLENCEANIMAL,
reason: tools.ozone.report.defs.reasonViolenceAnimal.value,
},
{
title: _(msg`Threats or incitement`),
reason: OzoneReportDefs.REASONVIOLENCETHREATS,
reason: tools.ozone.report.defs.reasonViolenceThreats.value,
},
{
title: _(msg`Graphic violent content`),
reason: OzoneReportDefs.REASONVIOLENCEGRAPHICCONTENT,
reason: tools.ozone.report.defs.reasonViolenceGraphicContent.value,
},
{
title: _(msg`Glorification of violence`),
reason: OzoneReportDefs.REASONVIOLENCEGLORIFICATION,
reason: tools.ozone.report.defs.reasonViolenceGlorification.value,
},
{
title: _(msg`Extremist content`),
reason: OzoneReportDefs.REASONVIOLENCEEXTREMISTCONTENT,
reason:
tools.ozone.report.defs.reasonViolenceExtremistContent.value,
},
{
title: _(msg`Human trafficking`),
reason: OzoneReportDefs.REASONVIOLENCETRAFFICKING,
reason: tools.ozone.report.defs.reasonViolenceTrafficking.value,
},
{
title: _(msg`Other violent content`),
reason: OzoneReportDefs.REASONVIOLENCEOTHER,
reason: tools.ozone.report.defs.reasonViolenceOther.value,
},
],
},
@@ -163,23 +165,23 @@ export function useReportOptions() {
options: [
{
title: _(msg`Child Sexual Abuse Material (CSAM)`),
reason: OzoneReportDefs.REASONCHILDSAFETYCSAM,
reason: tools.ozone.report.defs.reasonChildSafetyCSAM.value,
},
{
title: _(msg`Grooming or predatory behavior`),
reason: OzoneReportDefs.REASONCHILDSAFETYGROOM,
reason: tools.ozone.report.defs.reasonChildSafetyGroom.value,
},
{
title: _(msg`Privacy violation of a minor`),
reason: OzoneReportDefs.REASONCHILDSAFETYPRIVACY,
reason: tools.ozone.report.defs.reasonChildSafetyPrivacy.value,
},
{
title: _(msg`Minor harassment or bullying`),
reason: OzoneReportDefs.REASONCHILDSAFETYHARASSMENT,
reason: tools.ozone.report.defs.reasonChildSafetyHarassment.value,
},
{
title: _(msg`Other child safety issue`),
reason: OzoneReportDefs.REASONCHILDSAFETYOTHER,
reason: tools.ozone.report.defs.reasonChildSafetyOther.value,
},
],
},
@@ -190,23 +192,23 @@ export function useReportOptions() {
options: [
{
title: _(msg`Content promoting or depicting self-harm`),
reason: OzoneReportDefs.REASONSELFHARMCONTENT,
reason: tools.ozone.report.defs.reasonSelfHarmContent.value,
},
{
title: _(msg`Eating disorders`),
reason: OzoneReportDefs.REASONSELFHARMED,
reason: tools.ozone.report.defs.reasonSelfHarmED.value,
},
{
title: _(msg`Dangerous challenges or activities`),
reason: OzoneReportDefs.REASONSELFHARMSTUNTS,
reason: tools.ozone.report.defs.reasonSelfHarmStunts.value,
},
{
title: _(msg`Dangerous substances or drug abuse`),
reason: OzoneReportDefs.REASONSELFHARMSUBSTANCES,
reason: tools.ozone.report.defs.reasonSelfHarmSubstances.value,
},
{
title: _(msg`Other dangerous content`),
reason: OzoneReportDefs.REASONSELFHARMOTHER,
reason: tools.ozone.report.defs.reasonSelfHarmOther.value,
},
],
},
@@ -217,19 +219,19 @@ export function useReportOptions() {
options: [
{
title: _(msg`Hacking or system attacks`),
reason: OzoneReportDefs.REASONRULESITESECURITY,
reason: tools.ozone.report.defs.reasonRuleSiteSecurity.value,
},
{
title: _(msg`Promoting or selling prohibited items or services`),
reason: OzoneReportDefs.REASONRULEPROHIBITEDSALES,
reason: tools.ozone.report.defs.reasonRuleProhibitedSales.value,
},
{
title: _(msg`Banned user returning`),
reason: OzoneReportDefs.REASONRULEBANEVASION,
reason: tools.ozone.report.defs.reasonRuleBanEvasion.value,
},
{
title: _(msg`Other network rule-breaking`),
reason: OzoneReportDefs.REASONRULEOTHER,
reason: tools.ozone.report.defs.reasonRuleOther.value,
},
],
},
@@ -240,7 +242,7 @@ export function useReportOptions() {
options: [
{
title: _(msg`Other`),
reason: OzoneReportDefs.REASONOTHER,
reason: tools.ozone.report.defs.reasonOther.value,
},
],
},