swap the moderation core to the sdk moderation module
Point the moderation primitives - the label definitions, the cause/UI/decision types and the label-info hooks - at `@bsky.app/sdk/moderation` instead of `@atproto/api`. The two implementations are mutually unassignable: the sdk's subject types are the generated `#/lexicons` views, so their `did`/`uri`/`cid` fields are branded (`DidString`, `AtUriString`) where the `@atproto/api` views type the same fields as plain `string`. That rules out a partial swap - a decision made by one implementation cannot be read by the other - so the whole moderation layer moves together. `lib/moderation/subjects.ts` is the transitional seam for the brand mismatch. Every `moderate*` entry point is re-exported through a wrapper that widens its subject parameter to accept a view from either world, because many read paths still emit `@atproto/api` views while the moderation runtime only ever reads `.did`, `.labels` and `.viewer` - none of which the brand affects. It is deleted in the `@atproto/api` removal pass.
This commit is contained in:
@@ -4,8 +4,8 @@ import {
|
|||||||
AppBskyAgeassuranceDefs,
|
AppBskyAgeassuranceDefs,
|
||||||
computeAgeAssuranceRegionAccess,
|
computeAgeAssuranceRegionAccess,
|
||||||
getAgeAssuranceRegionConfig,
|
getAgeAssuranceRegionConfig,
|
||||||
type ModerationPrefs,
|
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
import {type ModerationPrefs} from '@bsky.app/sdk/moderation'
|
||||||
|
|
||||||
import {getAge} from '#/lib/strings/time'
|
import {getAge} from '#/lib/strings/time'
|
||||||
import {regionName} from '#/locale/helpers'
|
import {regionName} from '#/locale/helpers'
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {type AppBskyLabelerDefs} from '@atproto/api'
|
|
||||||
import {msg} from '@lingui/core/macro'
|
import {msg} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {Plural, Trans} from '@lingui/react/macro'
|
import {Plural, Trans} from '@lingui/react/macro'
|
||||||
@@ -13,10 +12,11 @@ import {Flag_Stroke2_Corner0_Rounded as Flag} from '#/components/icons/Flag'
|
|||||||
import {Link as InternalLink, type LinkProps} from '#/components/Link'
|
import {Link as InternalLink, type LinkProps} from '#/components/Link'
|
||||||
import {RichText} from '#/components/RichText'
|
import {RichText} from '#/components/RichText'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
import {type app} from '#/lexicons'
|
||||||
import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRight} from '../icons/Chevron'
|
import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRight} from '../icons/Chevron'
|
||||||
|
|
||||||
type LabelingServiceProps = {
|
type LabelingServiceProps = {
|
||||||
labeler: AppBskyLabelerDefs.LabelerViewDetailed
|
labeler: app.bsky.labeler.defs.LabelerViewDetailed
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Outer({
|
export function Outer({
|
||||||
@@ -187,7 +187,7 @@ export function Loader({
|
|||||||
loading?: React.ComponentType<{}>
|
loading?: React.ComponentType<{}>
|
||||||
error?: React.ComponentType<{error: string}>
|
error?: React.ComponentType<{error: string}>
|
||||||
component: React.ComponentType<{
|
component: React.ComponentType<{
|
||||||
labeler: AppBskyLabelerDefs.LabelerViewDetailed
|
labeler: app.bsky.labeler.defs.LabelerViewDetailed
|
||||||
}>
|
}>
|
||||||
}) {
|
}) {
|
||||||
const {isLoading, data, error} = useLabelerInfoQuery({did})
|
const {isLoading, data, error} = useLabelerInfoQuery({did})
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import {useMemo} from 'react'
|
import {useMemo} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {BSKY_LABELER_DID, type ModerationCause} from '@atproto/api'
|
|
||||||
import {Trans, useLingui} from '@lingui/react/macro'
|
import {Trans, useLingui} from '@lingui/react/macro'
|
||||||
|
import {BSKY_LABELER_DID} from '@atproto/api'
|
||||||
|
import {type ModerationCause} from '@bsky.app/sdk/moderation'
|
||||||
|
|
||||||
import {useModerationCauseDescription} from '#/lib/moderation/useModerationCauseDescription'
|
import {useModerationCauseDescription} from '#/lib/moderation/useModerationCauseDescription'
|
||||||
import {UserAvatar} from '#/view/com/util/UserAvatar'
|
import {UserAvatar} from '#/view/com/util/UserAvatar'
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
View,
|
View,
|
||||||
type ViewStyle,
|
type ViewStyle,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import {type ModerationUI} from '@atproto/api'
|
import {type ModerationUI} from '@bsky.app/sdk/moderation'
|
||||||
import {Trans, useLingui} from '@lingui/react/macro'
|
import {Trans, useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {createContext, useContext, useState} from 'react'
|
import {createContext, useContext, useState} from 'react'
|
||||||
import {type ModerationUI} from '@atproto/api'
|
import {type ModerationUI} from '@bsky.app/sdk/moderation'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type ModerationCauseDescription,
|
type ModerationCauseDescription,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {View} from 'react-native'
|
|||||||
import {
|
import {
|
||||||
type InterpretedLabelValueDefinition,
|
type InterpretedLabelValueDefinition,
|
||||||
type LabelPreference,
|
type LabelPreference,
|
||||||
} from '@atproto/api'
|
} from '@bsky.app/sdk/moderation'
|
||||||
import {msg} from '@lingui/core/macro'
|
import {msg} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {Trans} from '@lingui/react/macro'
|
import {Trans} from '@lingui/react/macro'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {useState} from 'react'
|
import {useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {type ModerationCause} from '@atproto/api'
|
import {type ModerationCause} from '@bsky.app/sdk/moderation'
|
||||||
import {msg} from '@lingui/core/macro'
|
import {msg} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {Trans} from '@lingui/react/macro'
|
import {Trans} from '@lingui/react/macro'
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
import {type StyleProp, View, type ViewStyle} from 'react-native'
|
import {type StyleProp, View, type ViewStyle} from 'react-native'
|
||||||
import {
|
import {type AppBskyFeedDefs, type ComAtprotoLabelDefs} from '@atproto/api'
|
||||||
type AppBskyFeedDefs,
|
import {type ModerationCause, type ModerationUI} from '@bsky.app/sdk/moderation'
|
||||||
type ComAtprotoLabelDefs,
|
|
||||||
type ModerationCause,
|
|
||||||
type ModerationUI,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {plural} from '@lingui/core/macro'
|
import {plural} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,8 @@ import {
|
|||||||
View,
|
View,
|
||||||
type ViewStyle,
|
type ViewStyle,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import {
|
import {type AppBskyActorDefs} from '@atproto/api'
|
||||||
type AppBskyActorDefs,
|
import {type ModerationCause, type ModerationUI} from '@bsky.app/sdk/moderation'
|
||||||
type ModerationCause,
|
|
||||||
type ModerationUI,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {msg} from '@lingui/core/macro'
|
import {msg} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {Trans} from '@lingui/react/macro'
|
import {Trans} from '@lingui/react/macro'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {type StyleProp, type ViewStyle} from 'react-native'
|
import {type StyleProp, type ViewStyle} from 'react-native'
|
||||||
import {type ModerationDecision} from '@atproto/api'
|
import {type ModerationDecision} from '@bsky.app/sdk/moderation'
|
||||||
|
|
||||||
import {getModerationCauseKey, unique} from '#/lib/moderation'
|
import {getModerationCauseKey, unique} from '#/lib/moderation'
|
||||||
import * as Pills from '#/components/Pills'
|
import * as Pills from '#/components/Pills'
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ export function useSubmitReportMutation() {
|
|||||||
* the proxy target is built per call from that labeler's creator did.
|
* the proxy target is built per call from that labeler's creator did.
|
||||||
*/
|
*/
|
||||||
await client.call(com.atproto.moderation.createReport, report, {
|
await client.call(com.atproto.moderation.createReport, report, {
|
||||||
service: `${labeler.creator.did as DidString}#atproto_labeler`,
|
service: `${labeler.creator.did}#atproto_labeler`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
useState,
|
useState,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
import {Pressable, type ScrollView, View} from 'react-native'
|
import {Pressable, type ScrollView, View} from 'react-native'
|
||||||
import {type AppBskyLabelerDefs, BSKY_LABELER_DID} from '@atproto/api'
|
import {BSKY_LABELER_DID} from '@atproto/api'
|
||||||
import {Trans, useLingui} from '@lingui/react/macro'
|
import {Trans, useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {wait} from '#/lib/async/wait'
|
import {wait} from '#/lib/async/wait'
|
||||||
@@ -38,6 +38,7 @@ import {Loader} from '#/components/Loader'
|
|||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
import {IS_NATIVE} from '#/env'
|
import {IS_NATIVE} from '#/env'
|
||||||
|
import {type app} from '#/lexicons'
|
||||||
import {useSubmitReportMutation} from './action'
|
import {useSubmitReportMutation} from './action'
|
||||||
import {
|
import {
|
||||||
BSKY_LABELER_ONLY_REPORT_REASONS,
|
BSKY_LABELER_ONLY_REPORT_REASONS,
|
||||||
@@ -1045,8 +1046,8 @@ function LabelerCard({
|
|||||||
labeler,
|
labeler,
|
||||||
onSelect,
|
onSelect,
|
||||||
}: {
|
}: {
|
||||||
labeler: AppBskyLabelerDefs.LabelerViewDetailed
|
labeler: app.bsky.labeler.defs.LabelerViewDetailed
|
||||||
onSelect?: (option: AppBskyLabelerDefs.LabelerViewDetailed) => void
|
onSelect?: (option: app.bsky.labeler.defs.LabelerViewDetailed) => void
|
||||||
}) {
|
}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import {
|
import {ToolsOzoneReportDefs as OzoneReportDefs} from '@atproto/api'
|
||||||
type AppBskyLabelerDefs,
|
|
||||||
ToolsOzoneReportDefs as OzoneReportDefs,
|
|
||||||
} from '@atproto/api'
|
|
||||||
|
|
||||||
|
import {type app} from '#/lexicons'
|
||||||
import {
|
import {
|
||||||
getNciiQualificationOutcome,
|
getNciiQualificationOutcome,
|
||||||
initialState,
|
initialState,
|
||||||
@@ -83,7 +81,7 @@ describe('reducer NCII qualification', () => {
|
|||||||
let state = selectNciiOption()
|
let state = selectNciiOption()
|
||||||
state = reducer(state, {
|
state = reducer(state, {
|
||||||
type: 'selectLabeler',
|
type: 'selectLabeler',
|
||||||
labeler: {} as AppBskyLabelerDefs.LabelerViewDetailed,
|
labeler: {} as app.bsky.labeler.defs.LabelerViewDetailed,
|
||||||
})
|
})
|
||||||
expect(state.activeStepIndex1).toBe(2)
|
expect(state.activeStepIndex1).toBe(2)
|
||||||
})
|
})
|
||||||
@@ -92,7 +90,7 @@ describe('reducer NCII qualification', () => {
|
|||||||
let state = selectNciiOption()
|
let state = selectNciiOption()
|
||||||
state = reducer(state, {
|
state = reducer(state, {
|
||||||
type: 'selectLabeler',
|
type: 'selectLabeler',
|
||||||
labeler: {} as AppBskyLabelerDefs.LabelerViewDetailed,
|
labeler: {} as app.bsky.labeler.defs.LabelerViewDetailed,
|
||||||
})
|
})
|
||||||
state = reducer(state, {
|
state = reducer(state, {
|
||||||
type: 'answerNciiQuestion',
|
type: 'answerNciiQuestion',
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import {
|
import {ToolsOzoneReportDefs as OzoneReportDefs} from '@atproto/api'
|
||||||
type AppBskyLabelerDefs,
|
|
||||||
ToolsOzoneReportDefs as OzoneReportDefs,
|
|
||||||
} from '@atproto/api'
|
|
||||||
|
|
||||||
import {OTHER_REPORT_REASONS} from '#/components/moderation/ReportDialog/const'
|
import {OTHER_REPORT_REASONS} from '#/components/moderation/ReportDialog/const'
|
||||||
import {
|
import {
|
||||||
type ReportCategoryConfig,
|
type ReportCategoryConfig,
|
||||||
type ReportOption,
|
type ReportOption,
|
||||||
} from '#/components/moderation/ReportDialog/utils/useReportOptions'
|
} from '#/components/moderation/ReportDialog/utils/useReportOptions'
|
||||||
|
import {type app} from '#/lexicons'
|
||||||
|
|
||||||
export type NciiQualification = {
|
export type NciiQualification = {
|
||||||
isDepicted?: boolean
|
isDepicted?: boolean
|
||||||
@@ -16,7 +14,7 @@ export type NciiQualification = {
|
|||||||
export type ReportState = {
|
export type ReportState = {
|
||||||
selectedCategory?: ReportCategoryConfig
|
selectedCategory?: ReportCategoryConfig
|
||||||
selectedOption?: ReportOption
|
selectedOption?: ReportOption
|
||||||
selectedLabeler?: AppBskyLabelerDefs.LabelerViewDetailed
|
selectedLabeler?: app.bsky.labeler.defs.LabelerViewDetailed
|
||||||
details?: string
|
details?: string
|
||||||
detailsOpen: boolean
|
detailsOpen: boolean
|
||||||
activeStepIndex1: number
|
activeStepIndex1: number
|
||||||
@@ -71,7 +69,7 @@ export type ReportAction =
|
|||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'selectLabeler'
|
type: 'selectLabeler'
|
||||||
labeler: AppBskyLabelerDefs.LabelerViewDetailed
|
labeler: app.bsky.labeler.defs.LabelerViewDetailed
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'clearLabeler'
|
type: 'clearLabeler'
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
View,
|
View,
|
||||||
type ViewStyle,
|
type ViewStyle,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import {type ModerationUI} from '@atproto/api'
|
import {type ModerationUI} from '@bsky.app/sdk/moderation'
|
||||||
import {Trans, useLingui} from '@lingui/react/macro'
|
import {Trans, useLingui} from '@lingui/react/macro'
|
||||||
import {useNavigation} from '@react-navigation/native'
|
import {useNavigation} from '@react-navigation/native'
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
import {useMemo} from 'react'
|
import {useMemo} from 'react'
|
||||||
|
import {AtpAgent, type ComAtprotoLabelDefs} from '@atproto/api'
|
||||||
import {
|
import {
|
||||||
type AppBskyLabelerDefs,
|
|
||||||
AtpAgent,
|
|
||||||
type ComAtprotoLabelDefs,
|
|
||||||
type InterpretedLabelValueDefinition,
|
type InterpretedLabelValueDefinition,
|
||||||
LABELS,
|
LABELS,
|
||||||
type ModerationCause,
|
type ModerationCause,
|
||||||
type ModerationOpts,
|
type ModerationOpts,
|
||||||
type ModerationUI,
|
type ModerationUI,
|
||||||
} from '@atproto/api'
|
} from '@bsky.app/sdk/moderation'
|
||||||
|
|
||||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
import {type AppModerationCause} from '#/components/Pills'
|
import {type AppModerationCause} from '#/components/Pills'
|
||||||
|
import {type app} from '#/lexicons'
|
||||||
|
|
||||||
export const ADULT_CONTENT_LABELS = ['sexual', 'nudity', 'porn'] as const
|
export const ADULT_CONTENT_LABELS = ['sexual', 'nudity', 'porn'] as const
|
||||||
export const OTHER_SELF_LABELS = ['graphic-media'] as const
|
export const OTHER_SELF_LABELS = ['graphic-media'] as const
|
||||||
@@ -102,8 +101,8 @@ export function lookupLabelValueDefinition(
|
|||||||
export function isAppLabeler(
|
export function isAppLabeler(
|
||||||
labeler:
|
labeler:
|
||||||
| string
|
| string
|
||||||
| AppBskyLabelerDefs.LabelerView
|
| app.bsky.labeler.defs.LabelerView
|
||||||
| AppBskyLabelerDefs.LabelerViewDetailed,
|
| app.bsky.labeler.defs.LabelerViewDetailed,
|
||||||
): boolean {
|
): boolean {
|
||||||
if (typeof labeler === 'string') {
|
if (typeof labeler === 'string') {
|
||||||
return AtpAgent.appLabelers.includes(labeler)
|
return AtpAgent.appLabelers.includes(labeler)
|
||||||
@@ -114,8 +113,8 @@ export function isAppLabeler(
|
|||||||
export function isLabelerSubscribed(
|
export function isLabelerSubscribed(
|
||||||
labeler:
|
labeler:
|
||||||
| string
|
| string
|
||||||
| AppBskyLabelerDefs.LabelerView
|
| app.bsky.labeler.defs.LabelerView
|
||||||
| AppBskyLabelerDefs.LabelerViewDetailed,
|
| app.bsky.labeler.defs.LabelerViewDetailed,
|
||||||
modOpts: ModerationOpts,
|
modOpts: ModerationOpts,
|
||||||
) {
|
) {
|
||||||
labeler = typeof labeler === 'string' ? labeler : labeler.creator.did
|
labeler = typeof labeler === 'string' ? labeler : labeler.creator.did
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {type ModerationUI} from '@atproto/api'
|
import {type ModerationUI} from '@bsky.app/sdk/moderation'
|
||||||
|
|
||||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
import {
|
||||||
|
type AppBskyActorDefs,
|
||||||
|
type AppBskyFeedDefs,
|
||||||
|
type AppBskyGraphDefs,
|
||||||
|
type AppBskyNotificationListNotifications,
|
||||||
|
type AppBskyRichtextFacet,
|
||||||
|
type ChatBskyActorDefs,
|
||||||
|
} from '@atproto/api'
|
||||||
|
import {
|
||||||
|
hasMutedWord as sdkHasMutedWord,
|
||||||
|
moderateFeedGenerator as sdkModerateFeedGenerator,
|
||||||
|
moderateNotification as sdkModerateNotification,
|
||||||
|
moderatePost as sdkModeratePost,
|
||||||
|
moderateProfile as sdkModerateProfile,
|
||||||
|
moderateStatus as sdkModerateStatus,
|
||||||
|
moderateUserList as sdkModerateUserList,
|
||||||
|
type ModerationDecision,
|
||||||
|
type ModerationOpts,
|
||||||
|
} from '@bsky.app/sdk/moderation'
|
||||||
|
|
||||||
|
import {type app, type chat} from '#/lexicons'
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TRANSITIONAL. The moderation implementation now comes from
|
||||||
|
* `@bsky.app/sdk/moderation`, whose subject types are the generated
|
||||||
|
* `#/lexicons` views - so their `did`/`uri`/`cid` fields are branded
|
||||||
|
* (`DidString`, `AtUriString`). Many read paths still emit the identically
|
||||||
|
* shaped `@atproto/api` views, whose same fields are plain `string`.
|
||||||
|
*
|
||||||
|
* A plain `string` is not assignable to a branded template-literal type, so
|
||||||
|
* every `moderate*` call taking an unmigrated view fails to typecheck even
|
||||||
|
* though the value is byte-identical - the runtime only ever reads `.did`,
|
||||||
|
* `.labels` and `.viewer`, none of which the brand affects.
|
||||||
|
*
|
||||||
|
* These wrappers widen each subject parameter to accept a view from either
|
||||||
|
* world and drop the brand on the way in. Delete this module once every
|
||||||
|
* producer emits `#/lexicons` views (the `@atproto/api` removal pass) and point
|
||||||
|
* callers back at `@bsky.app/sdk/moderation` directly.
|
||||||
|
*/
|
||||||
|
|
||||||
|
type AnyProfileSubject =
|
||||||
|
| app.bsky.actor.defs.ProfileViewBasic
|
||||||
|
| app.bsky.actor.defs.ProfileView
|
||||||
|
| app.bsky.actor.defs.ProfileViewDetailed
|
||||||
|
| chat.bsky.actor.defs.ProfileViewBasic
|
||||||
|
| AppBskyActorDefs.ProfileViewBasic
|
||||||
|
| AppBskyActorDefs.ProfileView
|
||||||
|
| AppBskyActorDefs.ProfileViewDetailed
|
||||||
|
| ChatBskyActorDefs.ProfileViewBasic
|
||||||
|
|
||||||
|
type AnyPostSubject = app.bsky.feed.defs.PostView | AppBskyFeedDefs.PostView
|
||||||
|
|
||||||
|
type AnyUserListSubject =
|
||||||
|
| app.bsky.graph.defs.ListViewBasic
|
||||||
|
| app.bsky.graph.defs.ListView
|
||||||
|
| AppBskyGraphDefs.ListViewBasic
|
||||||
|
| AppBskyGraphDefs.ListView
|
||||||
|
|
||||||
|
type AnyFeedGeneratorSubject =
|
||||||
|
| app.bsky.feed.defs.GeneratorView
|
||||||
|
| AppBskyFeedDefs.GeneratorView
|
||||||
|
|
||||||
|
type AnyNotificationSubject =
|
||||||
|
| app.bsky.notification.listNotifications.Notification
|
||||||
|
| AppBskyNotificationListNotifications.Notification
|
||||||
|
|
||||||
|
export function moderateProfile(
|
||||||
|
subject: AnyProfileSubject,
|
||||||
|
opts: ModerationOpts,
|
||||||
|
): ModerationDecision {
|
||||||
|
return sdkModerateProfile(subject as app.bsky.actor.defs.ProfileView, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function moderateStatus(
|
||||||
|
subject: AnyProfileSubject,
|
||||||
|
opts: ModerationOpts,
|
||||||
|
): ModerationDecision {
|
||||||
|
return sdkModerateStatus(subject as app.bsky.actor.defs.ProfileView, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function moderatePost(
|
||||||
|
subject: AnyPostSubject,
|
||||||
|
opts: ModerationOpts,
|
||||||
|
): ModerationDecision {
|
||||||
|
return sdkModeratePost(subject as app.bsky.feed.defs.PostView, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function moderateUserList(
|
||||||
|
subject: AnyUserListSubject,
|
||||||
|
opts: ModerationOpts,
|
||||||
|
): ModerationDecision {
|
||||||
|
return sdkModerateUserList(subject as app.bsky.graph.defs.ListView, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function moderateFeedGenerator(
|
||||||
|
subject: AnyFeedGeneratorSubject,
|
||||||
|
opts: ModerationOpts,
|
||||||
|
): ModerationDecision {
|
||||||
|
return sdkModerateFeedGenerator(
|
||||||
|
subject as app.bsky.feed.defs.GeneratorView,
|
||||||
|
opts,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function moderateNotification(
|
||||||
|
subject: AnyNotificationSubject,
|
||||||
|
opts: ModerationOpts,
|
||||||
|
): ModerationDecision {
|
||||||
|
return sdkModerateNotification(
|
||||||
|
subject as app.bsky.notification.listNotifications.Notification,
|
||||||
|
opts,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Widens `facets`/`actor` for the same reason the `moderate*` wrappers widen
|
||||||
|
* their subjects: mute-word matching reads only `text`/`features`/`langs`, none
|
||||||
|
* of which the brand affects.
|
||||||
|
*/
|
||||||
|
export function hasMutedWord(params: {
|
||||||
|
mutedWords: app.bsky.actor.defs.MutedWord[]
|
||||||
|
text: string
|
||||||
|
facets?: app.bsky.richtext.facet.Main[] | AppBskyRichtextFacet.Main[]
|
||||||
|
outlineTags?: string[]
|
||||||
|
languages?: string[]
|
||||||
|
actor?: AnyProfileSubject
|
||||||
|
}): boolean {
|
||||||
|
return sdkHasMutedWord({
|
||||||
|
...params,
|
||||||
|
facets: params.facets as app.bsky.richtext.facet.Main[] | undefined,
|
||||||
|
actor: params.actor as app.bsky.actor.defs.ProfileView | undefined,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
type InterpretedLabelValueDefinition,
|
type InterpretedLabelValueDefinition,
|
||||||
type LabelPreference,
|
type LabelPreference,
|
||||||
} from '@atproto/api'
|
} from '@bsky.app/sdk/moderation'
|
||||||
import {msg} from '@lingui/core/macro'
|
import {msg} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
|
import {type ComAtprotoLabelDefs} from '@atproto/api'
|
||||||
import {
|
import {
|
||||||
type AppBskyLabelerDefs,
|
|
||||||
type ComAtprotoLabelDefs,
|
|
||||||
type InterpretedLabelValueDefinition,
|
type InterpretedLabelValueDefinition,
|
||||||
interpretLabelValueDefinition,
|
interpretLabelValueDefinition,
|
||||||
LABELS,
|
LABELS,
|
||||||
} from '@atproto/api'
|
} from '@bsky.app/sdk/moderation'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import * as bcp47Match from 'bcp-47-match'
|
import * as bcp47Match from 'bcp-47-match'
|
||||||
|
|
||||||
@@ -13,12 +12,13 @@ import {
|
|||||||
useGlobalLabelStrings,
|
useGlobalLabelStrings,
|
||||||
} from '#/lib/moderation/useGlobalLabelStrings'
|
} from '#/lib/moderation/useGlobalLabelStrings'
|
||||||
import {useLabelDefinitions} from '#/state/preferences'
|
import {useLabelDefinitions} from '#/state/preferences'
|
||||||
|
import {type app} from '#/lexicons'
|
||||||
|
|
||||||
export interface LabelInfo {
|
export interface LabelInfo {
|
||||||
label: ComAtprotoLabelDefs.Label
|
label: ComAtprotoLabelDefs.Label
|
||||||
def: InterpretedLabelValueDefinition
|
def: InterpretedLabelValueDefinition
|
||||||
strings: ComAtprotoLabelDefs.LabelValueDefinitionStrings
|
strings: ComAtprotoLabelDefs.LabelValueDefinitionStrings
|
||||||
labeler: AppBskyLabelerDefs.LabelerViewDetailed | undefined
|
labeler: app.bsky.labeler.defs.LabelerViewDetailed | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useLabelInfo(label: ComAtprotoLabelDefs.Label): LabelInfo {
|
export function useLabelInfo(label: ComAtprotoLabelDefs.Label): LabelInfo {
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import {useMemo} from 'react'
|
import {useMemo} from 'react'
|
||||||
import {
|
import {BSKY_LABELER_DID} from '@atproto/api'
|
||||||
BSKY_LABELER_DID,
|
import {type ModerationCause} from '@bsky.app/sdk/moderation'
|
||||||
type ModerationCause,
|
|
||||||
type ModerationCauseSource,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {msg} from '@lingui/core/macro'
|
import {msg} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
@@ -25,7 +22,7 @@ export interface ModerationCauseDescription {
|
|||||||
description: string
|
description: string
|
||||||
source?: string
|
source?: string
|
||||||
sourceDisplayName?: string
|
sourceDisplayName?: string
|
||||||
sourceType?: ModerationCauseSource['type']
|
sourceType?: ModerationCause['source']['type']
|
||||||
sourceAvi?: string
|
sourceAvi?: string
|
||||||
sourceDid?: string
|
sourceDid?: string
|
||||||
isSubjectAccount?: boolean
|
isSubjectAccount?: boolean
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {type ModerationUI} from '@atproto/api'
|
import {type ModerationUI} from '@bsky.app/sdk/moderation'
|
||||||
|
|
||||||
// \u2705 = ✅
|
// \u2705 = ✅
|
||||||
// \u2713 = ✓
|
// \u2713 = ✓
|
||||||
|
|||||||
Reference in New Issue
Block a user