migrate runtime call sites to lex clients and sdk actions
Phase 3 tasks 3-7 (parallel wave): composer/post pipeline on pdsClient/appviewClient with structural+instance blob guards and a golden CID fixture test; chat Convo/EventBus/queries on the dedicated chat client; preferences sugar to SDK actions on the PDS client; remaining state/queries producers (usePostThread unspecced flip, video scoped-token clients, notifications, starter packs, lists) to client.call; UI runtime sweep (AtUri from @atproto/syntax, moderation fns from @bsky.app/sdk/moderation, SDK RichText, ozone reason tokens, guard rewrites via #/types/bsky). Intermediate checkpoint (hooks skipped): ~114 typecheck errors remain in cross-boundary consumer files, resolved by the type-only codemod next. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -632,11 +632,6 @@
|
|||||||
"count": 3
|
"count": 3
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"src/lib/api/feed/demo.ts": {
|
|
||||||
"typescript/require-await": {
|
|
||||||
"count": 2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"src/lib/api/feed/posts.ts": {
|
"src/lib/api/feed/posts.ts": {
|
||||||
"typescript/require-await": {
|
"typescript/require-await": {
|
||||||
"count": 1
|
"count": 1
|
||||||
@@ -1453,11 +1448,6 @@
|
|||||||
"count": 1
|
"count": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"src/state/queries/suggested-follows.ts": {
|
|
||||||
"no-unused-vars": {
|
|
||||||
"count": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"src/state/queries/threadgate/index.ts": {
|
"src/state/queries/threadgate/index.ts": {
|
||||||
"typescript/no-explicit-any": {
|
"typescript/no-explicit-any": {
|
||||||
"count": 1
|
"count": 1
|
||||||
|
|||||||
+4
-1
@@ -332,11 +332,14 @@
|
|||||||
"^multiformats/cid$": "<rootDir>/node_modules/multiformats/dist/src/cid.js",
|
"^multiformats/cid$": "<rootDir>/node_modules/multiformats/dist/src/cid.js",
|
||||||
"^multiformats/bases/base32$": "<rootDir>/node_modules/multiformats/dist/src/bases/base32.js",
|
"^multiformats/bases/base32$": "<rootDir>/node_modules/multiformats/dist/src/bases/base32.js",
|
||||||
"^multiformats/hashes/digest$": "<rootDir>/node_modules/multiformats/dist/src/hashes/digest.js",
|
"^multiformats/hashes/digest$": "<rootDir>/node_modules/multiformats/dist/src/hashes/digest.js",
|
||||||
|
"^multiformats/hashes/hasher$": "<rootDir>/node_modules/multiformats/dist/src/hashes/hasher.js",
|
||||||
"^multiformats/hashes/sha2$": "<rootDir>/node_modules/multiformats/dist/src/hashes/sha2.js",
|
"^multiformats/hashes/sha2$": "<rootDir>/node_modules/multiformats/dist/src/hashes/sha2.js",
|
||||||
"^uint8arrays/from-string$": "<rootDir>/node_modules/uint8arrays/dist/src/from-string.js",
|
"^uint8arrays/from-string$": "<rootDir>/node_modules/uint8arrays/dist/src/from-string.js",
|
||||||
"^uint8arrays/to-string$": "<rootDir>/node_modules/uint8arrays/dist/src/to-string.js",
|
"^uint8arrays/to-string$": "<rootDir>/node_modules/uint8arrays/dist/src/to-string.js",
|
||||||
"^unicode-segmenter/grapheme$": "<rootDir>/node_modules/unicode-segmenter/grapheme.cjs",
|
"^unicode-segmenter/grapheme$": "<rootDir>/node_modules/unicode-segmenter/grapheme.cjs",
|
||||||
"^await-lock$": "<rootDir>/node_modules/await-lock/build/AwaitLock.js"
|
"^await-lock$": "<rootDir>/node_modules/await-lock/build/AwaitLock.js",
|
||||||
|
"^@ipld/dag-cbor$": "<rootDir>/node_modules/@ipld/dag-cbor/src/index.js",
|
||||||
|
"^cborg$": "<rootDir>/node_modules/cborg/cborg.js"
|
||||||
},
|
},
|
||||||
"transformIgnorePatterns": [
|
"transformIgnorePatterns": [
|
||||||
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|nanoid|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|normalize-url|react-native-svg|@sentry/.*|sentry-expo|bcp-47-match|@atproto/.*|@bsky.app/sdk|tlds|multiformats|uint8arrays|@ipld/.*|cborg|await-lock)"
|
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|nanoid|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|normalize-url|react-native-svg|@sentry/.*|sentry-expo|bcp-47-match|@atproto/.*|@bsky.app/sdk|tlds|multiformats|uint8arrays|@ipld/.*|cborg|await-lock)"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {useCallback, useMemo} from 'react'
|
import {useCallback, useMemo} from 'react'
|
||||||
import {moderateProfile, type ModerationOpts} from '@atproto/api'
|
import {moderateProfile, type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
import {keepPreviousData, useQuery} from '@tanstack/react-query'
|
import {keepPreviousData, useQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {isJustAMute, moduiContainsHideableOffense} from '#/lib/moderation'
|
import {isJustAMute, moduiContainsHideableOffense} from '#/lib/moderation'
|
||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
type AutocompleteItemType,
|
type AutocompleteItemType,
|
||||||
type AutocompleteProfile,
|
type AutocompleteProfile,
|
||||||
} from '#/components/Autocomplete/types'
|
} from '#/components/Autocomplete/types'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
import {useEmojiSearch} from './useEmojiSearch'
|
import {useEmojiSearch} from './useEmojiSearch'
|
||||||
|
|
||||||
const DEFAULT_MOD_OPTS = {
|
const DEFAULT_MOD_OPTS = {
|
||||||
@@ -131,7 +132,10 @@ function moderateProfileItem({
|
|||||||
item: AutocompleteProfile
|
item: AutocompleteProfile
|
||||||
moderationOpts: ModerationOpts
|
moderationOpts: ModerationOpts
|
||||||
}) {
|
}) {
|
||||||
const modui = moderateProfile(item.profile, moderationOpts).ui('profileList')
|
// TODO(phase4): drop toLex once searchActorsTypeahead emits #/lexicons views
|
||||||
|
const modui = moderateProfile(toLex(item.profile), moderationOpts).ui(
|
||||||
|
'profileList',
|
||||||
|
)
|
||||||
const isExactMatch = query && item.profile.handle.toLowerCase() === query
|
const isExactMatch = query && item.profile.handle.toLowerCase() === query
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import Animated, {
|
|||||||
withDelay,
|
withDelay,
|
||||||
withTiming,
|
withTiming,
|
||||||
} from 'react-native-reanimated'
|
} from 'react-native-reanimated'
|
||||||
import {moderateProfile} from '@atproto/api'
|
import {moderateProfile} from '@bsky.app/sdk/moderation'
|
||||||
|
|
||||||
import {useMaybeProfileShadow} from '#/state/cache/profile-shadow'
|
import {useMaybeProfileShadow} from '#/state/cache/profile-shadow'
|
||||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||||
@@ -17,6 +17,7 @@ import {UserAvatar} from '#/view/com/util/UserAvatar'
|
|||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {Person_Filled_Corner2_Rounded as PersonIcon} from '#/components/icons/Person'
|
import {Person_Filled_Corner2_Rounded as PersonIcon} from '#/components/icons/Person'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
|
|
||||||
type Layout = {
|
type Layout = {
|
||||||
size: number
|
size: number
|
||||||
@@ -162,7 +163,10 @@ function AvatarBubble({
|
|||||||
type="user"
|
type="user"
|
||||||
hideLiveBadge
|
hideLiveBadge
|
||||||
noBorder
|
noBorder
|
||||||
moderation={moderateProfile(profile, moderationOpts).ui('avatar')}
|
// TODO(phase4): drop toLex once profile props emit #/lexicons views
|
||||||
|
moderation={moderateProfile(toLex(profile), moderationOpts).ui(
|
||||||
|
'avatar',
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<AvatarPlaceholder size={size} />
|
<AvatarPlaceholder size={size} />
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {moderateProfile} from '@atproto/api'
|
import {moderateProfile} from '@bsky.app/sdk/moderation'
|
||||||
|
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||||
@@ -7,6 +7,7 @@ import {useProfilesQuery} from '#/state/queries/profile'
|
|||||||
import {UserAvatar} from '#/view/com/util/UserAvatar'
|
import {UserAvatar} from '#/view/com/util/UserAvatar'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
|
|
||||||
export function AvatarStack({
|
export function AvatarStack({
|
||||||
profiles,
|
profiles,
|
||||||
@@ -34,7 +35,8 @@ export function AvatarStack({
|
|||||||
: profiles.map(item => ({
|
: profiles.map(item => ({
|
||||||
key: item.did,
|
key: item.did,
|
||||||
profile: item,
|
profile: item,
|
||||||
moderation: moderateProfile(item, moderationOpts),
|
// TODO(phase4): drop toLex once useProfilesQuery emits #/lexicons views
|
||||||
|
moderation: moderateProfile(toLex(item), moderationOpts),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
import {useCallback, useEffect, useMemo} from 'react'
|
import {useCallback, useEffect, useMemo} from 'react'
|
||||||
import {type GestureResponderEvent, View} from 'react-native'
|
import {type GestureResponderEvent, View} from 'react-native'
|
||||||
import {
|
import {type AppBskyFeedDefs, type AppBskyGraphDefs} from '@atproto/api'
|
||||||
type AppBskyFeedDefs,
|
import {AtUri} from '@atproto/syntax'
|
||||||
type AppBskyGraphDefs,
|
import {RichText as RichTextApi} from '@bsky.app/sdk/richtext'
|
||||||
AtUri,
|
|
||||||
RichText as RichTextApi,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {Plural, Trans, useLingui} from '@lingui/react/macro'
|
import {Plural, Trans, useLingui} from '@lingui/react/macro'
|
||||||
import {useQueryClient} from '@tanstack/react-query'
|
import {useQueryClient} from '@tanstack/react-query'
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import {useRef} from 'react'
|
import {useRef} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {
|
import {type AppBskyActorDefs} from '@atproto/api'
|
||||||
type AppBskyActorDefs,
|
import {moderateProfile, type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
moderateProfile,
|
|
||||||
type ModerationOpts,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {Plural, Trans, useLingui} from '@lingui/react/macro'
|
import {Plural, Trans, useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {makeProfileLink} from '#/lib/routes/links'
|
import {makeProfileLink} from '#/lib/routes/links'
|
||||||
@@ -14,6 +11,7 @@ import {atoms as a, useTheme} from '#/alf'
|
|||||||
import {Link, type LinkProps} from '#/components/Link'
|
import {Link, type LinkProps} from '#/components/Link'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
|
|
||||||
const AVI_SIZE = 30
|
const AVI_SIZE = 30
|
||||||
const AVI_SIZE_SMALL = 20
|
const AVI_SIZE_SMALL = 20
|
||||||
@@ -96,7 +94,8 @@ function KnownFollowersInner({
|
|||||||
const textStyle = [a.text_sm, a.leading_snug, t.atoms.text_contrast_medium]
|
const textStyle = [a.text_sm, a.leading_snug, t.atoms.text_contrast_medium]
|
||||||
|
|
||||||
const slice = cachedKnownFollowers.followers.slice(0, 3).map(f => {
|
const slice = cachedKnownFollowers.followers.slice(0, 3).map(f => {
|
||||||
const moderation = moderateProfile(f, moderationOpts)
|
// TODO(phase4): drop toLex once KnownFollowers emits #/lexicons views
|
||||||
|
const moderation = moderateProfile(toLex(f), moderationOpts)
|
||||||
return {
|
return {
|
||||||
profile: {
|
profile: {
|
||||||
...f,
|
...f,
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
import {useEffect, useMemo} from 'react'
|
import {useEffect, useMemo} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {
|
import {type AppBskyGraphDefs} from '@atproto/api'
|
||||||
type AppBskyGraphDefs,
|
import {AtUri} from '@atproto/syntax'
|
||||||
AtUri,
|
import {moderateUserList, type ModerationUI} from '@bsky.app/sdk/moderation'
|
||||||
moderateUserList,
|
|
||||||
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'
|
||||||
@@ -27,6 +24,7 @@ import {Link as InternalLink, type LinkProps} from '#/components/Link'
|
|||||||
import * as Hider from '#/components/moderation/Hider'
|
import * as Hider from '#/components/moderation/Hider'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This component is based on `FeedCard` and is tightly coupled with that
|
* This component is based on `FeedCard` and is tightly coupled with that
|
||||||
@@ -57,7 +55,8 @@ export function Default(
|
|||||||
const {view, showPinButton} = props
|
const {view, showPinButton} = props
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
const moderation = moderationOpts
|
const moderation = moderationOpts
|
||||||
? moderateUserList(view, moderationOpts)
|
? // TODO(phase4): drop toLex once ListView props emit #/lexicons views
|
||||||
|
moderateUserList(toLex(view), moderationOpts)
|
||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {useMemo, useState} from 'react'
|
import {useMemo, useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {type AppBskyActorDefs, moderateProfile} from '@atproto/api'
|
import {type AppBskyActorDefs} from '@atproto/api'
|
||||||
|
import {moderateProfile} 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'
|
||||||
@@ -19,6 +20,7 @@ import {Newskie} from '#/components/icons/Newskie'
|
|||||||
import * as StarterPackCard from '#/components/StarterPack/StarterPackCard'
|
import * as StarterPackCard from '#/components/StarterPack/StarterPackCard'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {IS_NATIVE} from '#/env'
|
import {IS_NATIVE} from '#/env'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
|
|
||||||
export function NewskieDialog({
|
export function NewskieDialog({
|
||||||
profile,
|
profile,
|
||||||
@@ -88,7 +90,8 @@ function DialogInner({
|
|||||||
|
|
||||||
const profileName = useMemo(() => {
|
const profileName = useMemo(() => {
|
||||||
if (!moderationOpts) return profile.displayName || profile.handle
|
if (!moderationOpts) return profile.displayName || profile.handle
|
||||||
const moderation = moderateProfile(profile, moderationOpts)
|
// TODO(phase4): drop toLex once ProfileViewDetailed prop emits #/lexicons views
|
||||||
|
const moderation = moderateProfile(toLex(profile), moderationOpts)
|
||||||
return sanitizeDisplayName(
|
return sanitizeDisplayName(
|
||||||
profile.displayName || profile.handle,
|
profile.displayName || profile.handle,
|
||||||
moderation.ui('displayName'),
|
moderation.ui('displayName'),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
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 {api} from '@bsky.app/sdk'
|
||||||
|
import {type ModerationCause} from '@bsky.app/sdk/moderation'
|
||||||
import {Trans} from '@lingui/react/macro'
|
import {Trans} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {useModerationCauseDescription} from '#/lib/moderation/useModerationCauseDescription'
|
import {useModerationCauseDescription} from '#/lib/moderation/useModerationCauseDescription'
|
||||||
@@ -65,7 +66,7 @@ export function Label({
|
|||||||
const desc = useModerationCauseDescription(cause)
|
const desc = useModerationCauseDescription(cause)
|
||||||
const isLabeler = Boolean(desc.sourceType && desc.sourceDid)
|
const isLabeler = Boolean(desc.sourceType && desc.sourceDid)
|
||||||
const isBlueskyLabel =
|
const isBlueskyLabel =
|
||||||
desc.sourceType === 'labeler' && desc.sourceDid === BSKY_LABELER_DID
|
desc.sourceType === 'labeler' && desc.sourceDid === api.moderation.did
|
||||||
const avi = size === 'lg' ? 16 : 12
|
const avi = size === 'lg' ? 16 : 12
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import {useMemo} from 'react'
|
import {useMemo} from 'react'
|
||||||
import {moderateFeedGenerator} from '@atproto/api'
|
import {moderateFeedGenerator} from '@bsky.app/sdk/moderation'
|
||||||
|
|
||||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import * as FeedCard from '#/components/FeedCard'
|
import * as FeedCard from '#/components/FeedCard'
|
||||||
import {ContentHider} from '#/components/moderation/ContentHider'
|
import {ContentHider} from '#/components/moderation/ContentHider'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
import {type EmbedType} from '#/types/bsky/post'
|
import {type EmbedType} from '#/types/bsky/post'
|
||||||
import {type CommonProps} from './types'
|
import {type CommonProps} from './types'
|
||||||
|
|
||||||
@@ -40,7 +41,8 @@ export function ModeratedFeedEmbed({
|
|||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
const moderation = useMemo(() => {
|
const moderation = useMemo(() => {
|
||||||
return moderationOpts
|
return moderationOpts
|
||||||
? moderateFeedGenerator(embed.view, moderationOpts)
|
? // TODO(phase4): drop toLex once feed embed view emits #/lexicons views
|
||||||
|
moderateFeedGenerator(toLex(embed.view), moderationOpts)
|
||||||
: undefined
|
: undefined
|
||||||
}, [embed.view, moderationOpts])
|
}, [embed.view, moderationOpts])
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import {useMemo} from 'react'
|
import {useMemo} from 'react'
|
||||||
import {moderateUserList} from '@atproto/api'
|
import {moderateUserList} from '@bsky.app/sdk/moderation'
|
||||||
|
|
||||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import * as ListCard from '#/components/ListCard'
|
import * as ListCard from '#/components/ListCard'
|
||||||
import {ContentHider} from '#/components/moderation/ContentHider'
|
import {ContentHider} from '#/components/moderation/ContentHider'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
import {type EmbedType} from '#/types/bsky/post'
|
import {type EmbedType} from '#/types/bsky/post'
|
||||||
import {type CommonProps} from './types'
|
import {type CommonProps} from './types'
|
||||||
|
|
||||||
@@ -30,7 +31,8 @@ export function ModeratedListEmbed({
|
|||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
const moderation = useMemo(() => {
|
const moderation = useMemo(() => {
|
||||||
return moderationOpts
|
return moderationOpts
|
||||||
? moderateUserList(embed.view, moderationOpts)
|
? // TODO(phase4): drop toLex once list embed view emits #/lexicons views
|
||||||
|
moderateUserList(toLex(embed.view), moderationOpts)
|
||||||
: undefined
|
: undefined
|
||||||
}, [embed.view, moderationOpts])
|
}, [embed.view, moderationOpts])
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {Fragment, type ReactNode} from 'react'
|
import {Fragment, type ReactNode} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {AtUri} from '@atproto/api'
|
import {AtUri} from '@atproto/syntax'
|
||||||
import {Trans} from '@lingui/react/macro'
|
import {Trans} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {toNiceDomain} from '#/lib/strings/url-helpers'
|
import {toNiceDomain} from '#/lib/strings/url-helpers'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {type StyleProp, View, type ViewStyle} from 'react-native'
|
import {type StyleProp, View, type ViewStyle} from 'react-native'
|
||||||
import {Image} from 'expo-image'
|
import {Image} from 'expo-image'
|
||||||
import {AtUri} from '@atproto/api'
|
import {AtUri} from '@atproto/syntax'
|
||||||
import {plural} from '@lingui/core/macro'
|
import {plural} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
type AppBskyEmbedExternal,
|
type AppBskyEmbedExternal,
|
||||||
AtUri,
|
|
||||||
type ComAtprotoRepoStrongRef,
|
type ComAtprotoRepoStrongRef,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
import {AtUri} from '@atproto/syntax'
|
||||||
|
|
||||||
export function isStandardSiteDocumentUri(ref: ComAtprotoRepoStrongRef.Main) {
|
export function isStandardSiteDocumentUri(ref: ComAtprotoRepoStrongRef.Main) {
|
||||||
return new AtUri(ref.uri).collection.startsWith('site.standard.document')
|
return new AtUri(ref.uri).collection.startsWith('site.standard.document')
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
import {useCallback, useMemo} from 'react'
|
import {useCallback, useMemo} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {
|
import {type AppBskyFeedDefs} from '@atproto/api'
|
||||||
type $Typed,
|
import {type $Typed} from '@atproto/lex'
|
||||||
type AppBskyFeedDefs,
|
import {AtUri} from '@atproto/syntax'
|
||||||
AppBskyFeedPost,
|
import {moderatePost} from '@bsky.app/sdk/moderation'
|
||||||
AtUri,
|
import {RichText as RichTextAPI} from '@bsky.app/sdk/richtext'
|
||||||
moderatePost,
|
|
||||||
RichText as RichTextAPI,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {Trans} from '@lingui/react/macro'
|
import {Trans} from '@lingui/react/macro'
|
||||||
import {useQueryClient} from '@tanstack/react-query'
|
import {useQueryClient} from '@tanstack/react-query'
|
||||||
|
|
||||||
@@ -28,6 +25,7 @@ import {isStandardSiteEmbed} from '#/components/Post/Embed/StandardSiteEmbed/uti
|
|||||||
import {RichText} from '#/components/RichText'
|
import {RichText} from '#/components/RichText'
|
||||||
import {Embed as StarterPackCard} from '#/components/StarterPack/StarterPackCard'
|
import {Embed as StarterPackCard} from '#/components/StarterPack/StarterPackCard'
|
||||||
import {SubtleHover} from '#/components/SubtleHover'
|
import {SubtleHover} from '#/components/SubtleHover'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
import {
|
import {
|
||||||
type Embed as TEmbed,
|
type Embed as TEmbed,
|
||||||
@@ -271,7 +269,9 @@ export function QuoteEmbed({
|
|||||||
[embed],
|
[embed],
|
||||||
)
|
)
|
||||||
const moderation = useMemo(() => {
|
const moderation = useMemo(() => {
|
||||||
return moderationOpts ? moderatePost(quote, moderationOpts) : undefined
|
return moderationOpts
|
||||||
|
? moderatePost(bsky.toLex(quote), moderationOpts)
|
||||||
|
: undefined
|
||||||
}, [quote, moderationOpts])
|
}, [quote, moderationOpts])
|
||||||
|
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
@@ -281,13 +281,7 @@ export function QuoteEmbed({
|
|||||||
const itemTitle = `Post by ${quote.author.handle}`
|
const itemTitle = `Post by ${quote.author.handle}`
|
||||||
|
|
||||||
const richText = useMemo(() => {
|
const richText = useMemo(() => {
|
||||||
if (
|
if (!bsky.isType(app.bsky.feed.post, quote.record)) return undefined
|
||||||
!bsky.dangerousIsType<AppBskyFeedPost.Record>(
|
|
||||||
quote.record,
|
|
||||||
AppBskyFeedPost.isRecord,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return undefined
|
|
||||||
const {text, facets} = quote.record
|
const {text, facets} = quote.record
|
||||||
return text.trim()
|
return text.trim()
|
||||||
? new RichTextAPI({text: text, facets: facets})
|
? new RichTextAPI({text: text, facets: facets})
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import {type StyleProp, type ViewStyle} from 'react-native'
|
import {type StyleProp, type ViewStyle} from 'react-native'
|
||||||
import {type AppBskyFeedDefs, type ModerationDecision} from '@atproto/api'
|
import {type AppBskyFeedDefs} from '@atproto/api'
|
||||||
|
import {type ModerationDecision} from '@bsky.app/sdk/moderation'
|
||||||
|
|
||||||
export enum PostEmbedViewContext {
|
export enum PostEmbedViewContext {
|
||||||
ThreadHighlighted = 'ThreadHighlighted',
|
ThreadHighlighted = 'ThreadHighlighted',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {useCallback, useMemo} from 'react'
|
import {useCallback, useMemo} from 'react'
|
||||||
import {Platform, type StyleProp, type TextStyle, View} from 'react-native'
|
import {Platform, type StyleProp, type TextStyle, View} from 'react-native'
|
||||||
import {type AppBskyFeedDefs, AppBskyFeedPost} from '@atproto/api'
|
import {type AppBskyFeedDefs, type AppBskyFeedPost} from '@atproto/api'
|
||||||
import {Trans, useLingui} from '@lingui/react/macro'
|
import {Trans, useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {HITSLOP_30} from '#/lib/constants'
|
import {HITSLOP_30} from '#/lib/constants'
|
||||||
@@ -28,6 +28,7 @@ import * as Select from '#/components/Select'
|
|||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
import {IS_WEB} from '#/env'
|
import {IS_WEB} from '#/env'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
const X_ICON_OFFSET = 16
|
const X_ICON_OFFSET = 16
|
||||||
@@ -47,10 +48,7 @@ export function TranslatedPost({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const record = useMemo<AppBskyFeedPost.Record | undefined>(() => {
|
const record = useMemo<AppBskyFeedPost.Record | undefined>(() => {
|
||||||
return bsky.dangerousIsType<AppBskyFeedPost.Record>(
|
return bsky.isType(app.bsky.feed.post, post.record)
|
||||||
post.record,
|
|
||||||
AppBskyFeedPost.isRecord,
|
|
||||||
)
|
|
||||||
? post.record
|
? post.record
|
||||||
: undefined
|
: undefined
|
||||||
}, [post])
|
}, [post])
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import {
|
|||||||
type AppBskyFeedDefs,
|
type AppBskyFeedDefs,
|
||||||
type AppBskyFeedPost,
|
type AppBskyFeedPost,
|
||||||
type AppBskyFeedThreadgate,
|
type AppBskyFeedThreadgate,
|
||||||
AtUri,
|
|
||||||
type RichText as RichTextAPI,
|
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
import {AtUri} from '@atproto/syntax'
|
||||||
|
import {type RichText as RichTextAPI} from '@bsky.app/sdk/richtext'
|
||||||
import {plural} from '@lingui/core/macro'
|
import {plural} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
import {useNavigation} from '@react-navigation/native'
|
import {useNavigation} from '@react-navigation/native'
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import {
|
|||||||
type AppBskyFeedDefs,
|
type AppBskyFeedDefs,
|
||||||
type AppBskyFeedPost,
|
type AppBskyFeedPost,
|
||||||
type AppBskyFeedThreadgate,
|
type AppBskyFeedThreadgate,
|
||||||
type RichText as RichTextAPI,
|
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
import {type RichText as RichTextAPI} from '@bsky.app/sdk/richtext'
|
||||||
import {useLingui} from '@lingui/react/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {type Shadow} from '#/state/cache/post-shadow'
|
import {type Shadow} from '#/state/cache/post-shadow'
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import {ScrollView, View} from 'react-native'
|
import {ScrollView, View} from 'react-native'
|
||||||
import {
|
import {type ChatBskyActorDefs} from '@atproto/api'
|
||||||
type ChatBskyActorDefs,
|
import {moderateProfile, type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
moderateProfile,
|
|
||||||
type ModerationOpts,
|
|
||||||
} 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'
|
||||||
@@ -25,6 +22,7 @@ import {type ConvoWithDetails, parseConvoView} from '#/components/dms/util'
|
|||||||
import {ProfileBadges} from '#/components/ProfileBadges'
|
import {ProfileBadges} from '#/components/ProfileBadges'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
|
|
||||||
export function RecentChats({
|
export function RecentChats({
|
||||||
postUri,
|
postUri,
|
||||||
@@ -123,7 +121,8 @@ function RecentChatItem({
|
|||||||
|
|
||||||
const primaryProfile = useProfileShadow(primaryMember)
|
const primaryProfile = useProfileShadow(primaryMember)
|
||||||
|
|
||||||
const moderation = moderateProfile(primaryProfile, moderationOpts)
|
// TODO(phase4): drop toLex once useProfileShadow emits #/lexicons views
|
||||||
|
const moderation = moderateProfile(toLex(primaryProfile), moderationOpts)
|
||||||
const name =
|
const name =
|
||||||
convo.kind === 'group'
|
convo.kind === 'group'
|
||||||
? convo.details.name
|
? convo.details.name
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {memo, useMemo} from 'react'
|
import {memo, useMemo} from 'react'
|
||||||
import * as ExpoClipboard from 'expo-clipboard'
|
import * as ExpoClipboard from 'expo-clipboard'
|
||||||
import {AtUri} from '@atproto/api'
|
import {AtUri} from '@atproto/syntax'
|
||||||
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'
|
||||||
import {useQueryClient} from '@tanstack/react-query'
|
import {useQueryClient} from '@tanstack/react-query'
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import {
|
|||||||
type AppBskyFeedDefs,
|
type AppBskyFeedDefs,
|
||||||
type AppBskyFeedPost,
|
type AppBskyFeedPost,
|
||||||
type AppBskyFeedThreadgate,
|
type AppBskyFeedThreadgate,
|
||||||
type RichText as RichTextAPI,
|
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
import {type RichText as RichTextAPI} from '@bsky.app/sdk/richtext'
|
||||||
|
|
||||||
import {type Shadow} from '#/state/cache/post-shadow'
|
import {type Shadow} from '#/state/cache/post-shadow'
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {memo, useMemo} from 'react'
|
import {memo, useMemo} from 'react'
|
||||||
import {AtUri} from '@atproto/api'
|
import {AtUri} from '@atproto/syntax'
|
||||||
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'
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import {
|
|||||||
type AppBskyFeedDefs,
|
type AppBskyFeedDefs,
|
||||||
type AppBskyFeedPost,
|
type AppBskyFeedPost,
|
||||||
type AppBskyFeedThreadgate,
|
type AppBskyFeedThreadgate,
|
||||||
AtUri,
|
|
||||||
type RichText as RichTextAPI,
|
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
import {AtUri} from '@atproto/syntax'
|
||||||
|
import {type RichText as RichTextAPI} from '@bsky.app/sdk/richtext'
|
||||||
import {msg} from '@lingui/core/macro'
|
import {msg} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import {
|
|||||||
type AppBskyFeedDefs,
|
type AppBskyFeedDefs,
|
||||||
type AppBskyFeedPost,
|
type AppBskyFeedPost,
|
||||||
type AppBskyFeedThreadgate,
|
type AppBskyFeedThreadgate,
|
||||||
type RichText as RichTextAPI,
|
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
import {type RichText as RichTextAPI} from '@bsky.app/sdk/richtext'
|
||||||
import {plural} from '@lingui/core/macro'
|
import {plural} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,8 @@ import {
|
|||||||
View,
|
View,
|
||||||
type ViewStyle,
|
type ViewStyle,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import {
|
import {moderateProfile, type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
moderateProfile,
|
import {RichText as RichTextApi} from '@bsky.app/sdk/richtext'
|
||||||
type ModerationOpts,
|
|
||||||
RichText as RichTextApi,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {useLingui} from '@lingui/react/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {getModerationCauseKey} from '#/lib/moderation'
|
import {getModerationCauseKey} from '#/lib/moderation'
|
||||||
@@ -47,7 +44,7 @@ import * as Toast from '#/components/Toast'
|
|||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {type Metrics} from '#/analytics'
|
import {type Metrics} from '#/analytics'
|
||||||
import {useActorStatus} from '#/features/liveNow'
|
import {useActorStatus} from '#/features/liveNow'
|
||||||
import type * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
export function Default({
|
export function Default({
|
||||||
profile,
|
profile,
|
||||||
@@ -173,7 +170,7 @@ export function Avatar({
|
|||||||
liveOverride?: boolean
|
liveOverride?: boolean
|
||||||
size?: number
|
size?: number
|
||||||
}) {
|
}) {
|
||||||
const moderation = moderateProfile(profile, moderationOpts)
|
const moderation = moderateProfile(bsky.toLex(profile), moderationOpts)
|
||||||
|
|
||||||
const {isActive: live} = useActorStatus(profile)
|
const {isActive: live} = useActorStatus(profile)
|
||||||
|
|
||||||
@@ -243,7 +240,7 @@ function InlineNameAndHandle({
|
|||||||
moderationOpts: ModerationOpts
|
moderationOpts: ModerationOpts
|
||||||
}) {
|
}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const moderation = moderateProfile(profile, moderationOpts)
|
const moderation = moderateProfile(bsky.toLex(profile), moderationOpts)
|
||||||
const name = sanitizeDisplayName(
|
const name = sanitizeDisplayName(
|
||||||
profile.displayName || sanitizeHandle(profile.handle),
|
profile.displayName || sanitizeHandle(profile.handle),
|
||||||
moderation.ui('displayName'),
|
moderation.ui('displayName'),
|
||||||
@@ -297,7 +294,7 @@ export function Name({
|
|||||||
style?: StyleProp<ViewStyle>
|
style?: StyleProp<ViewStyle>
|
||||||
textStyle?: StyleProp<TextStyle>
|
textStyle?: StyleProp<TextStyle>
|
||||||
}) {
|
}) {
|
||||||
const moderation = moderateProfile(profile, moderationOpts)
|
const moderation = moderateProfile(bsky.toLex(profile), moderationOpts)
|
||||||
const name = sanitizeDisplayName(
|
const name = sanitizeDisplayName(
|
||||||
profile.displayName || sanitizeHandle(profile.handle),
|
profile.displayName || sanitizeHandle(profile.handle),
|
||||||
moderation.ui('displayName'),
|
moderation.ui('displayName'),
|
||||||
@@ -482,7 +479,7 @@ export function FollowButtonInner({
|
|||||||
}: FollowButtonProps) {
|
}: FollowButtonProps) {
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const profile = useProfileShadow(profileUnshadowed)
|
const profile = useProfileShadow(profileUnshadowed)
|
||||||
const moderation = moderateProfile(profile, moderationOpts)
|
const moderation = moderateProfile(bsky.toLex(profile), moderationOpts)
|
||||||
const [queueFollow, queueUnfollow] = useProfileFollowMutationQueue(
|
const [queueFollow, queueUnfollow] = useProfileFollowMutationQueue(
|
||||||
profile,
|
profile,
|
||||||
logContext,
|
logContext,
|
||||||
@@ -620,7 +617,7 @@ export function Labels({
|
|||||||
profile: bsky.profile.AnyProfileView
|
profile: bsky.profile.AnyProfileView
|
||||||
moderationOpts: ModerationOpts
|
moderationOpts: ModerationOpts
|
||||||
}) {
|
}) {
|
||||||
const moderation = moderateProfile(profile, moderationOpts)
|
const moderation = moderateProfile(bsky.toLex(profile), moderationOpts)
|
||||||
const modui = moderation.ui('profileList')
|
const modui = moderation.ui('profileList')
|
||||||
const followedBy = profile.viewer?.followedBy
|
const followedBy = profile.viewer?.followedBy
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import {memo, useCallback, useEffect, useMemo, useReducer, useRef} from 'react'
|
import {memo, useCallback, useEffect, useMemo, useReducer, useRef} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {
|
import {type AppBskyActorDefs} from '@atproto/api'
|
||||||
type AppBskyActorDefs,
|
import {moderateProfile, type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
moderateProfile,
|
|
||||||
type ModerationOpts,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {flip, offset, shift, size, useFloating} from '@floating-ui/react-dom'
|
import {flip, offset, shift, size, useFloating} from '@floating-ui/react-dom'
|
||||||
import {msg, plural} from '@lingui/core/macro'
|
import {msg, plural} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
@@ -42,6 +39,7 @@ import {Text} from '#/components/Typography'
|
|||||||
import {IS_WEB_TOUCH_DEVICE} from '#/env'
|
import {IS_WEB_TOUCH_DEVICE} from '#/env'
|
||||||
import {useActorStatus} from '#/features/liveNow'
|
import {useActorStatus} from '#/features/liveNow'
|
||||||
import {LiveStatus} from '#/features/liveNow/components/LiveStatusDialog'
|
import {LiveStatus} from '#/features/liveNow/components/LiveStatusDialog'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
import {type ProfileHoverCardProps} from './types'
|
import {type ProfileHoverCardProps} from './types'
|
||||||
|
|
||||||
const floatingMiddlewares = [
|
const floatingMiddlewares = [
|
||||||
@@ -426,7 +424,8 @@ function Inner({
|
|||||||
const {_, i18n} = useLingui()
|
const {_, i18n} = useLingui()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const moderation = useMemo(
|
const moderation = useMemo(
|
||||||
() => moderateProfile(profile, moderationOpts),
|
// TODO(phase4): drop toLex once ProfileViewDetailed prop emits #/lexicons views
|
||||||
|
() => moderateProfile(toLex(profile), moderationOpts),
|
||||||
[profile, moderationOpts],
|
[profile, moderationOpts],
|
||||||
)
|
)
|
||||||
const [descriptionRT] = useRichText(profile.description ?? '')
|
const [descriptionRT] = useRichText(profile.description ?? '')
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {memo, useCallback, useEffect, useMemo, useRef, useState} from 'react'
|
import {memo, useCallback, useEffect, useMemo, useRef, useState} from 'react'
|
||||||
import {TextInput, View, type ViewToken} from 'react-native'
|
import {TextInput, View, type ViewToken} from 'react-native'
|
||||||
import {type ModerationOpts} from '@atproto/api'
|
import {type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
import {Trans, useLingui} from '@lingui/react/macro'
|
import {Trans, useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
|
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
import {forwardRef, useCallback, useImperativeHandle, useState} from 'react'
|
import {forwardRef, useCallback, useImperativeHandle, useState} from 'react'
|
||||||
import {type ListRenderItemInfo, View} from 'react-native'
|
import {type ListRenderItemInfo, View} from 'react-native'
|
||||||
import {
|
import {type AppBskyActorDefs, type AppBskyGraphGetList} from '@atproto/api'
|
||||||
type AppBskyActorDefs,
|
import {AtUri} from '@atproto/syntax'
|
||||||
type AppBskyGraphGetList,
|
import {type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
AtUri,
|
|
||||||
type ModerationOpts,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {
|
import {
|
||||||
type InfiniteData,
|
type InfiniteData,
|
||||||
type UseInfiniteQueryResult,
|
type UseInfiniteQueryResult,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {View} from 'react-native'
|
|||||||
// @ts-expect-error missing types
|
// @ts-expect-error missing types
|
||||||
import QRCode from 'react-native-qrcode-styled'
|
import QRCode from 'react-native-qrcode-styled'
|
||||||
import type ViewShot from 'react-native-view-shot'
|
import type ViewShot from 'react-native-view-shot'
|
||||||
import {type AppBskyGraphDefs, AppBskyGraphStarterpack} from '@atproto/api'
|
import {type AppBskyGraphDefs} from '@atproto/api'
|
||||||
import {Trans} from '@lingui/react/macro'
|
import {Trans} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {Logo} from '#/view/icons/Logo'
|
import {Logo} from '#/view/icons/Logo'
|
||||||
@@ -12,6 +12,7 @@ import {atoms as a, useTheme} from '#/alf'
|
|||||||
import {LinearGradientBackground} from '#/components/LinearGradientBackground'
|
import {LinearGradientBackground} from '#/components/LinearGradientBackground'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {IS_WEB} from '#/env'
|
import {IS_WEB} from '#/env'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
const LazyViewShot = lazy(
|
const LazyViewShot = lazy(
|
||||||
@@ -30,12 +31,7 @@ export function QrCode({
|
|||||||
}) {
|
}) {
|
||||||
const {record} = starterPack
|
const {record} = starterPack
|
||||||
|
|
||||||
if (
|
if (!bsky.isType(app.bsky.graph.starterpack, record)) {
|
||||||
!bsky.dangerousIsType<AppBskyGraphStarterpack.Record>(
|
|
||||||
record,
|
|
||||||
AppBskyGraphStarterpack.isRecord,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {View} from 'react-native'
|
|||||||
import type ViewShot from 'react-native-view-shot'
|
import type ViewShot from 'react-native-view-shot'
|
||||||
import {requestPermissionsAsync, saveToLibraryAsync} from 'expo-media-library'
|
import {requestPermissionsAsync, saveToLibraryAsync} from 'expo-media-library'
|
||||||
import * as Sharing from 'expo-sharing'
|
import * as Sharing from 'expo-sharing'
|
||||||
import {type AppBskyGraphDefs, AppBskyGraphStarterpack} from '@atproto/api'
|
import {type AppBskyGraphDefs} 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'
|
||||||
@@ -21,6 +21,7 @@ import {QrCode} from '#/components/StarterPack/QrCode'
|
|||||||
import * as Toast from '#/components/Toast'
|
import * as Toast from '#/components/Toast'
|
||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
import {IS_NATIVE, IS_WEB} from '#/env'
|
import {IS_NATIVE, IS_WEB} from '#/env'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
export function QrCodeDialog({
|
export function QrCodeDialog({
|
||||||
@@ -87,12 +88,7 @@ export function QrCodeDialog({
|
|||||||
} else {
|
} else {
|
||||||
setIsSaveProcessing(true)
|
setIsSaveProcessing(true)
|
||||||
|
|
||||||
if (
|
if (!bsky.matches(app.bsky.graph.starterpack, starterPack.record)) {
|
||||||
!bsky.validate(
|
|
||||||
starterPack.record,
|
|
||||||
AppBskyGraphStarterpack.validateRecord,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {useMemo} from 'react'
|
import {useMemo} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {Image} from 'expo-image'
|
import {Image} from 'expo-image'
|
||||||
import {AppBskyGraphStarterpack, AtUri} from '@atproto/api'
|
import {AtUri} from '@atproto/syntax'
|
||||||
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'
|
||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
type LinkProps as BaseLinkProps,
|
type LinkProps as BaseLinkProps,
|
||||||
} from '#/components/Link'
|
} from '#/components/Link'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
export function Default({
|
export function Default({
|
||||||
@@ -62,12 +63,7 @@ export function Card({
|
|||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
|
||||||
if (
|
if (!bsky.isType(app.bsky.graph.starterpack, record)) {
|
||||||
!bsky.dangerousIsType<AppBskyGraphStarterpack.Record>(
|
|
||||||
record,
|
|
||||||
AppBskyGraphStarterpack.isRecord,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,10 +123,7 @@ export function useStarterPackLink({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
to: `/starter-pack/${handleOrDid}/${rkey}`,
|
to: `/starter-pack/${handleOrDid}/${rkey}`,
|
||||||
label: bsky.dangerousIsType<AppBskyGraphStarterpack.Record>(
|
label: bsky.isType(app.bsky.graph.starterpack, view.record)
|
||||||
view.record,
|
|
||||||
AppBskyGraphStarterpack.isRecord,
|
|
||||||
)
|
|
||||||
? _(msg`Navigate to ${view.record.name}`)
|
? _(msg`Navigate to ${view.record.name}`)
|
||||||
: _(msg`Navigate to starter pack`),
|
: _(msg`Navigate to starter pack`),
|
||||||
precache,
|
precache,
|
||||||
@@ -154,12 +147,7 @@ export function Link({
|
|||||||
return {rkey, handleOrDid: creator.handle || creator.did}
|
return {rkey, handleOrDid: creator.handle || creator.did}
|
||||||
}, [starterPack])
|
}, [starterPack])
|
||||||
|
|
||||||
if (
|
if (!bsky.isType(app.bsky.graph.starterpack, record)) {
|
||||||
!bsky.dangerousIsType<AppBskyGraphStarterpack.Record>(
|
|
||||||
record,
|
|
||||||
AppBskyGraphStarterpack.isRecord,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
import {useRef} from 'react'
|
import {useRef} from 'react'
|
||||||
import {type ListRenderItemInfo} from 'react-native'
|
import {type ListRenderItemInfo} from 'react-native'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {
|
import {type AppBskyActorDefs, type AppBskyFeedDefs} from '@atproto/api'
|
||||||
type AppBskyActorDefs,
|
import {type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
type AppBskyFeedDefs,
|
|
||||||
type ModerationOpts,
|
|
||||||
} 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,12 +1,11 @@
|
|||||||
import {Keyboard, View} from 'react-native'
|
import {Keyboard, View} from 'react-native'
|
||||||
|
import {type AppBskyActorDefs, type AppBskyFeedDefs} from '@atproto/api'
|
||||||
import {
|
import {
|
||||||
type AppBskyActorDefs,
|
|
||||||
type AppBskyFeedDefs,
|
|
||||||
moderateFeedGenerator,
|
moderateFeedGenerator,
|
||||||
moderateProfile,
|
moderateProfile,
|
||||||
type ModerationOpts,
|
type ModerationOpts,
|
||||||
type ModerationUI,
|
type ModerationUI,
|
||||||
} 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'
|
||||||
@@ -27,6 +26,7 @@ import {Checkbox} from '#/components/forms/Toggle'
|
|||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
|
|
||||||
function WizardListCard({
|
function WizardListCard({
|
||||||
type,
|
type,
|
||||||
@@ -140,7 +140,10 @@ export function WizardProfileCard({
|
|||||||
const included = isTarget || state.profiles.some(p => p.did === profile.did)
|
const included = isTarget || state.profiles.some(p => p.did === profile.did)
|
||||||
const disabled =
|
const disabled =
|
||||||
isTarget || (!included && state.profiles.length >= STARTER_PACK_MAX_SIZE)
|
isTarget || (!included && state.profiles.length >= STARTER_PACK_MAX_SIZE)
|
||||||
const moderationUi = moderateProfile(profile, moderationOpts).ui('avatar')
|
// TODO(phase4): drop toLex once profile prop emits #/lexicons views
|
||||||
|
const moderationUi = moderateProfile(toLex(profile), moderationOpts).ui(
|
||||||
|
'avatar',
|
||||||
|
)
|
||||||
const displayName = profile.displayName
|
const displayName = profile.displayName
|
||||||
? sanitizeDisplayName(profile.displayName)
|
? sanitizeDisplayName(profile.displayName)
|
||||||
: `@${sanitizeHandle(profile.handle)}`
|
: `@${sanitizeHandle(profile.handle)}`
|
||||||
@@ -191,9 +194,11 @@ export function WizardFeedCard({
|
|||||||
const isDiscover = generator.uri === DISCOVER_FEED_URI
|
const isDiscover = generator.uri === DISCOVER_FEED_URI
|
||||||
const included = isDiscover || state.feeds.some(f => f.uri === generator.uri)
|
const included = isDiscover || state.feeds.some(f => f.uri === generator.uri)
|
||||||
const disabled = isDiscover || (!included && state.feeds.length >= 3)
|
const disabled = isDiscover || (!included && state.feeds.length >= 3)
|
||||||
const moderationUi = moderateFeedGenerator(generator, moderationOpts).ui(
|
// TODO(phase4): drop toLex once GeneratorView prop emits #/lexicons views
|
||||||
'avatar',
|
const moderationUi = moderateFeedGenerator(
|
||||||
)
|
toLex(generator),
|
||||||
|
moderationOpts,
|
||||||
|
).ui('avatar')
|
||||||
|
|
||||||
const onPress = () => {
|
const onPress = () => {
|
||||||
if (disabled) return
|
if (disabled) return
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {useEffect, useMemo} from 'react'
|
import {useEffect, useMemo} from 'react'
|
||||||
import {type AppBskyUnspeccedDefs, type AtUri} from '@atproto/api'
|
import {type AtUri} from '@atproto/syntax'
|
||||||
import {useLingui} from '@lingui/react/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {PressableScale} from '#/lib/custom-animations/PressableScale'
|
import {PressableScale} from '#/lib/custom-animations/PressableScale'
|
||||||
@@ -9,6 +9,7 @@ import {useCallOnce} from '#/lib/once'
|
|||||||
import {native} from '#/alf'
|
import {native} from '#/alf'
|
||||||
import {Link as InternalLink, type LinkProps} from '#/components/Link'
|
import {Link as InternalLink, type LinkProps} from '#/components/Link'
|
||||||
import {type Metrics, useAnalytics} from '#/analytics'
|
import {type Metrics, useAnalytics} from '#/analytics'
|
||||||
|
import {type app} from '#/lexicons'
|
||||||
|
|
||||||
export function TrendingTopicLink({
|
export function TrendingTopicLink({
|
||||||
topic: raw,
|
topic: raw,
|
||||||
@@ -18,7 +19,7 @@ export function TrendingTopicLink({
|
|||||||
children,
|
children,
|
||||||
...rest
|
...rest
|
||||||
}: {
|
}: {
|
||||||
topic: AppBskyUnspeccedDefs.TrendView
|
topic: app.bsky.unspecced.defs.TrendView
|
||||||
metricContext: Metrics['trendingTopic:seen']['context']
|
metricContext: Metrics['trendingTopic:seen']['context']
|
||||||
rank: number
|
rank: number
|
||||||
recId?: string
|
recId?: string
|
||||||
@@ -75,7 +76,7 @@ type ParsedTrendingTopic =
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function useTopic(
|
export function useTopic(
|
||||||
raw: AppBskyUnspeccedDefs.TrendView,
|
raw: app.bsky.unspecced.defs.TrendView,
|
||||||
): ParsedTrendingTopic {
|
): ParsedTrendingTopic {
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ import {
|
|||||||
type AppBskyActorDefs,
|
type AppBskyActorDefs,
|
||||||
AppBskyEmbedVideo,
|
AppBskyEmbedVideo,
|
||||||
type AppBskyFeedDefs,
|
type AppBskyFeedDefs,
|
||||||
AppBskyFeedPost,
|
|
||||||
type ModerationDecision,
|
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
import {type ModerationDecision} from '@bsky.app/sdk/moderation'
|
||||||
import {useLingui} from '@lingui/react/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
@@ -26,6 +25,7 @@ import {Link} from '#/components/Link'
|
|||||||
import {MediaInsetBorder} from '#/components/MediaInsetBorder'
|
import {MediaInsetBorder} from '#/components/MediaInsetBorder'
|
||||||
import * as Hider from '#/components/moderation/Hider'
|
import * as Hider from '#/components/moderation/Hider'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
function getBlackColor(t: ReturnType<typeof useTheme>) {
|
function getBlackColor(t: ReturnType<typeof useTheme>) {
|
||||||
@@ -78,10 +78,7 @@ export function VideoPostCard({
|
|||||||
if (!AppBskyEmbedVideo.isView(embed)) return null
|
if (!AppBskyEmbedVideo.isView(embed)) return null
|
||||||
|
|
||||||
const author = post.author
|
const author = post.author
|
||||||
const text = bsky.dangerousIsType<AppBskyFeedPost.Record>(
|
const text = bsky.isType(app.bsky.feed.post, post.record)
|
||||||
post.record,
|
|
||||||
AppBskyFeedPost.isRecord,
|
|
||||||
)
|
|
||||||
? post.record?.text
|
? post.record?.text
|
||||||
: ''
|
: ''
|
||||||
const likeCount = post?.likeCount ?? 0
|
const likeCount = post?.likeCount ?? 0
|
||||||
|
|||||||
@@ -6,12 +6,8 @@ import {
|
|||||||
View,
|
View,
|
||||||
type ViewStyle,
|
type ViewStyle,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import {
|
import {type AppBskyFeedDefs, type AppBskyGraphDefs} from '@atproto/api'
|
||||||
type AppBskyFeedDefs,
|
import {AtUri} from '@atproto/syntax'
|
||||||
AppBskyFeedPost,
|
|
||||||
type AppBskyGraphDefs,
|
|
||||||
AtUri,
|
|
||||||
} 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'
|
||||||
@@ -38,6 +34,7 @@ import {InlineLinkText} from '#/components/Link'
|
|||||||
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 {app} from '#/lexicons'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
interface WhoCanReplyProps {
|
interface WhoCanReplyProps {
|
||||||
@@ -58,10 +55,7 @@ export function WhoCanReply({post, isThreadAuthor, style}: WhoCanReplyProps) {
|
|||||||
* unexpectedly, we should check to make sure it's for sure the root URI.
|
* unexpectedly, we should check to make sure it's for sure the root URI.
|
||||||
*/
|
*/
|
||||||
const rootUri =
|
const rootUri =
|
||||||
bsky.dangerousIsType<AppBskyFeedPost.Record>(
|
bsky.isType(app.bsky.feed.post, post.record) && post.record.reply?.root
|
||||||
post.record,
|
|
||||||
AppBskyFeedPost.isRecord,
|
|
||||||
) && post.record.reply?.root
|
|
||||||
? post.record.reply.root.uri
|
? post.record.reply.root.uri
|
||||||
: post.uri
|
: post.uri
|
||||||
const settings = useMemo(() => {
|
const settings = useMemo(() => {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {useCallback, useEffect, useState} from 'react'
|
import {useCallback, useEffect, useState} from 'react'
|
||||||
import {type ModerationOpts} from '@atproto/api'
|
import {type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
import {Trans, useLingui} from '@lingui/react/macro'
|
import {Trans, useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {useRequireEmailVerification} from '#/lib/hooks/useRequireEmailVerification'
|
import {useRequireEmailVerification} from '#/lib/hooks/useRequireEmailVerification'
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import {View} from 'react-native'
|
|||||||
import {
|
import {
|
||||||
type AppBskyNotificationDefs,
|
type AppBskyNotificationDefs,
|
||||||
type AppBskyNotificationListActivitySubscriptions,
|
type AppBskyNotificationListActivitySubscriptions,
|
||||||
type ModerationOpts,
|
|
||||||
type Un$Typed,
|
type Un$Typed,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
import {type ModerationOpts} 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,13 +1,12 @@
|
|||||||
import {useState} from 'react'
|
import {useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {ToolsOzoneReportDefs} from '@atproto/api'
|
import {api} from '@bsky.app/sdk'
|
||||||
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'
|
||||||
import {useMutation} from '@tanstack/react-query'
|
import {useMutation} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {BLUESKY_MOD_SERVICE_HEADERS} from '#/lib/constants'
|
import {usePdsClient, useSession} from '#/state/session'
|
||||||
import {useAgent, useSession} from '#/state/session'
|
|
||||||
import {atoms as a, useBreakpoints, web} from '#/alf'
|
import {atoms as a, useBreakpoints, web} from '#/alf'
|
||||||
import {AgeAssuranceBadge} from '#/components/ageAssurance/AgeAssuranceBadge'
|
import {AgeAssuranceBadge} from '#/components/ageAssurance/AgeAssuranceBadge'
|
||||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
@@ -17,6 +16,8 @@ import * as Toast from '#/components/Toast'
|
|||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {logger} from '#/ageAssurance'
|
import {logger} from '#/ageAssurance'
|
||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
|
import {com, tools} from '#/lexicons'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
|
|
||||||
export function AgeAssuranceAppealDialog({
|
export function AgeAssuranceAppealDialog({
|
||||||
control,
|
control,
|
||||||
@@ -42,7 +43,7 @@ function Inner({control}: {control: Dialog.DialogControlProps}) {
|
|||||||
const ax = useAnalytics()
|
const ax = useAnalytics()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const {gtPhone} = useBreakpoints()
|
const {gtPhone} = useBreakpoints()
|
||||||
const agent = useAgent()
|
const pdsClient = usePdsClient()
|
||||||
|
|
||||||
const [details, setDetails] = useState('')
|
const [details, setDetails] = useState('')
|
||||||
const isInvalid = details.length > 1000
|
const isInvalid = details.length > 1000
|
||||||
@@ -51,18 +52,18 @@ function Inner({control}: {control: Dialog.DialogControlProps}) {
|
|||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
ax.metric('ageAssurance:appealDialogSubmit', {})
|
ax.metric('ageAssurance:appealDialogSubmit', {})
|
||||||
|
|
||||||
await agent.createModerationReport(
|
await pdsClient.call(
|
||||||
{
|
com.atproto.moderation.createReport,
|
||||||
reasonType: ToolsOzoneReportDefs.REASONAPPEAL,
|
toLex<com.atproto.moderation.createReport.$InputBody>({
|
||||||
|
reasonType: tools.ozone.report.defs.reasonAppeal.value,
|
||||||
subject: {
|
subject: {
|
||||||
$type: 'com.atproto.admin.defs#repoRef',
|
$type: 'com.atproto.admin.defs#repoRef',
|
||||||
did: currentAccount?.did,
|
did: currentAccount?.did,
|
||||||
},
|
},
|
||||||
reason: `AGE_ASSURANCE_INQUIRY: ` + details,
|
reason: `AGE_ASSURANCE_INQUIRY: ` + details,
|
||||||
},
|
}),
|
||||||
{
|
{
|
||||||
encoding: 'application/json',
|
service: api.moderation.service,
|
||||||
headers: BLUESKY_MOD_SERVICE_HEADERS,
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import {useState} from 'react'
|
import {useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {XRPCError} 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'
|
||||||
@@ -14,6 +13,7 @@ import {
|
|||||||
import {useGetTimeAgo} from '#/lib/hooks/useTimeAgo'
|
import {useGetTimeAgo} from '#/lib/hooks/useTimeAgo'
|
||||||
import {useTLDs} from '#/lib/hooks/useTLDs'
|
import {useTLDs} from '#/lib/hooks/useTLDs'
|
||||||
import {isEmailMaybeInvalid} from '#/lib/strings/email'
|
import {isEmailMaybeInvalid} from '#/lib/strings/email'
|
||||||
|
import {getErrorName, isXrpcError} from '#/lib/xrpc-error'
|
||||||
import {type AppLanguage} from '#/locale/languages'
|
import {type AppLanguage} from '#/locale/languages'
|
||||||
import {useLanguagePrefs} from '#/state/preferences'
|
import {useLanguagePrefs} from '#/state/preferences'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
@@ -139,13 +139,14 @@ function Inner() {
|
|||||||
msg`Something went wrong, please try again`,
|
msg`Something went wrong, please try again`,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (e instanceof XRPCError) {
|
if (isXrpcError(e)) {
|
||||||
if (e.error === 'InvalidEmail') {
|
const errorName = getErrorName(e)
|
||||||
|
if (errorName === 'InvalidEmail') {
|
||||||
error = _(
|
error = _(
|
||||||
msg`Please enter a valid, non-temporary email address. You may need to access this email in the future.`,
|
msg`Please enter a valid, non-temporary email address. You may need to access this email in the future.`,
|
||||||
)
|
)
|
||||||
ax.metric('ageAssurance:initDialogError', {code: 'InvalidEmail'})
|
ax.metric('ageAssurance:initDialogError', {code: 'InvalidEmail'})
|
||||||
} else if (e.error === 'DidTooLong') {
|
} else if (errorName === 'DidTooLong') {
|
||||||
error = (
|
error = (
|
||||||
<>
|
<>
|
||||||
<Trans>
|
<Trans>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {useCallback, useMemo, useRef, useState} from 'react'
|
|||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||||
import * as SMS from 'expo-sms'
|
import * as SMS from 'expo-sms'
|
||||||
import {type ModerationOpts} from '@atproto/api'
|
import {type ModerationOpts} 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 {Plural, Trans} from '@lingui/react/macro'
|
import {Plural, Trans} from '@lingui/react/macro'
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {memo, useEffect, useMemo, useState} from 'react'
|
import {memo, useEffect, useMemo, useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {type AppBskyActorDefs, type AppBskyFeedPost, AtUri} from '@atproto/api'
|
import {type AppBskyActorDefs, type AppBskyFeedPost} from '@atproto/api'
|
||||||
|
import {AtUri} from '@atproto/syntax'
|
||||||
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,7 @@
|
|||||||
import {useCallback, useMemo, useState} from 'react'
|
import {useCallback, useMemo, useState} from 'react'
|
||||||
import {LayoutAnimation, Text as NestedText, View} from 'react-native'
|
import {LayoutAnimation, Text as NestedText, View} from 'react-native'
|
||||||
import {
|
import {type AppBskyFeedDefs, type AppBskyFeedPostgate} from '@atproto/api'
|
||||||
type AppBskyFeedDefs,
|
import {AtUri} from '@atproto/syntax'
|
||||||
type AppBskyFeedPostgate,
|
|
||||||
AtUri,
|
|
||||||
} 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'
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
useState,
|
useState,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
import {TextInput, View} from 'react-native'
|
import {TextInput, View} from 'react-native'
|
||||||
import {moderateProfile, type ModerationOpts} from '@atproto/api'
|
import {moderateProfile, type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
import {Plural, Trans, useLingui} from '@lingui/react/macro'
|
import {Plural, Trans, useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {createSanitizedDisplayName} from '#/lib/moderation/create-sanitized-display-name'
|
import {createSanitizedDisplayName} from '#/lib/moderation/create-sanitized-display-name'
|
||||||
@@ -33,6 +33,7 @@ import * as ProfileCard from '#/components/ProfileCard'
|
|||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {IS_WEB} from '#/env'
|
import {IS_WEB} from '#/env'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
import {AvatarBubbles} from '../AvatarBubbles'
|
import {AvatarBubbles} from '../AvatarBubbles'
|
||||||
import {Error} from '../Error'
|
import {Error} from '../Error'
|
||||||
import {ProfileBadges} from '../ProfileBadges'
|
import {ProfileBadges} from '../ProfileBadges'
|
||||||
@@ -410,7 +411,8 @@ function DefaultProfileCard({
|
|||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const enabled = canBeMessaged(profile)
|
const enabled = canBeMessaged(profile)
|
||||||
const moderation = moderateProfile(profile, moderationOpts)
|
// TODO(phase4): drop toLex once profile prop emits #/lexicons views
|
||||||
|
const moderation = moderateProfile(toLex(profile), moderationOpts)
|
||||||
const handle = sanitizeHandle(profile.handle, '@')
|
const handle = sanitizeHandle(profile.handle, '@')
|
||||||
const displayName = createSanitizedDisplayName(
|
const displayName = createSanitizedDisplayName(
|
||||||
profile,
|
profile,
|
||||||
@@ -486,7 +488,8 @@ function ExistingChatCard({
|
|||||||
: createSanitizedDisplayName(
|
: createSanitizedDisplayName(
|
||||||
convo.primaryMember,
|
convo.primaryMember,
|
||||||
true,
|
true,
|
||||||
moderateProfile(convo.primaryMember, moderationOpts).ui(
|
// TODO(phase4): drop toLex once convo primaryMember emits #/lexicons views
|
||||||
|
moderateProfile(toLex(convo.primaryMember), moderationOpts).ui(
|
||||||
'displayName',
|
'displayName',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import {useCallback} from 'react'
|
import {useCallback} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {
|
import {type AppBskyGraphGetStarterPacksWithMembership} from '@atproto/api'
|
||||||
type AppBskyGraphGetStarterPacksWithMembership,
|
|
||||||
AppBskyGraphStarterpack,
|
|
||||||
} 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'
|
||||||
@@ -33,6 +30,7 @@ import * as Toast from '#/components/Toast'
|
|||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
import {IS_WEB} from '#/env'
|
import {IS_WEB} from '#/env'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
type StarterPackWithMembership =
|
type StarterPackWithMembership =
|
||||||
@@ -324,12 +322,7 @@ function StarterPackItem({
|
|||||||
|
|
||||||
const {record} = starterPack
|
const {record} = starterPack
|
||||||
|
|
||||||
if (
|
if (!bsky.isType(app.bsky.graph.starterpack, record)) {
|
||||||
!bsky.dangerousIsType<AppBskyGraphStarterpack.Record>(
|
|
||||||
record,
|
|
||||||
AppBskyGraphStarterpack.isRecord,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import {
|
|||||||
type AppBskyGraphDefs,
|
type AppBskyGraphDefs,
|
||||||
type AppBskyGraphListitem,
|
type AppBskyGraphListitem,
|
||||||
type AppBskyGraphStarterpack,
|
type AppBskyGraphStarterpack,
|
||||||
AtUri,
|
|
||||||
type ComAtprotoRepoApplyWrites,
|
type ComAtprotoRepoApplyWrites,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
import {TID} from '@atproto/common-web'
|
import {TID} from '@atproto/common-web'
|
||||||
|
import {AtUri} from '@atproto/syntax'
|
||||||
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,7 @@
|
|||||||
import {useCallback, useEffect, useMemo, useState} from 'react'
|
import {useCallback, useEffect, useMemo, useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {type AppBskyGraphDefs, RichText as RichTextAPI} from '@atproto/api'
|
import {type AppBskyGraphDefs} from '@atproto/api'
|
||||||
|
import {RichText as RichTextAPI} from '@bsky.app/sdk/richtext'
|
||||||
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'
|
||||||
@@ -15,7 +16,7 @@ import {
|
|||||||
useListCreateMutation,
|
useListCreateMutation,
|
||||||
useListMetadataMutation,
|
useListMetadataMutation,
|
||||||
} from '#/state/queries/list'
|
} from '#/state/queries/list'
|
||||||
import {useAgent} from '#/state/session'
|
import {usePdsClient} from '#/state/session'
|
||||||
import {ErrorMessage} from '#/view/com/util/error/ErrorMessage'
|
import {ErrorMessage} from '#/view/com/util/error/ErrorMessage'
|
||||||
import {EditableUserAvatar} from '#/view/com/util/UserAvatar'
|
import {EditableUserAvatar} from '#/view/com/util/UserAvatar'
|
||||||
import {atoms as a, useTheme, web} from '#/alf'
|
import {atoms as a, useTheme, web} from '#/alf'
|
||||||
@@ -27,6 +28,7 @@ import * as Prompt from '#/components/Prompt'
|
|||||||
import * as Toast from '#/components/Toast'
|
import * as Toast from '#/components/Toast'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {IS_WEB} from '#/env'
|
import {IS_WEB} from '#/env'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
|
|
||||||
const DISPLAY_NAME_MAX_GRAPHEMES = 64
|
const DISPLAY_NAME_MAX_GRAPHEMES = 64
|
||||||
const DESCRIPTION_MAX_GRAPHEMES = 300
|
const DESCRIPTION_MAX_GRAPHEMES = 300
|
||||||
@@ -133,7 +135,7 @@ function DialogInner({
|
|||||||
|
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const agent = useAgent()
|
const pdsClient = usePdsClient()
|
||||||
const control = Dialog.useDialogContext()
|
const control = Dialog.useDialogContext()
|
||||||
const {
|
const {
|
||||||
mutateAsync: createListMutation,
|
mutateAsync: createListMutation,
|
||||||
@@ -163,7 +165,11 @@ function DialogInner({
|
|||||||
|
|
||||||
// We want to be working with a blank state here, so let's get the
|
// We want to be working with a blank state here, so let's get the
|
||||||
// serialized version and turn it back into a RichText
|
// serialized version and turn it back into a RichText
|
||||||
const serialized = richTextToString(new RichTextAPI({text, facets}), false)
|
// TODO(phase4): drop toLex once the list view producer emits #/lexicons facets
|
||||||
|
const serialized = richTextToString(
|
||||||
|
new RichTextAPI({text, facets: toLex(facets)}),
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
|
||||||
const richText = new RichTextAPI({text: serialized})
|
const richText = new RichTextAPI({text: serialized})
|
||||||
richText.detectFacetsWithoutResolution()
|
richText.detectFacetsWithoutResolution()
|
||||||
@@ -224,7 +230,7 @@ function DialogInner({
|
|||||||
{cleanNewlines: true},
|
{cleanNewlines: true},
|
||||||
)
|
)
|
||||||
|
|
||||||
await richText.detectFacets(agent)
|
await richText.detectFacets(pdsClient)
|
||||||
richText = shortenLinks(richText)
|
richText = shortenLinks(richText)
|
||||||
richText = stripInvalidMentions(richText)
|
richText = stripInvalidMentions(richText)
|
||||||
|
|
||||||
@@ -272,7 +278,7 @@ function DialogInner({
|
|||||||
setImageError,
|
setImageError,
|
||||||
activePurpose,
|
activePurpose,
|
||||||
isCurateList,
|
isCurateList,
|
||||||
agent,
|
pdsClient,
|
||||||
_,
|
_,
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {useCallback, useMemo} from 'react'
|
import {useCallback, useMemo} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {type AppBskyGraphDefs, type ModerationOpts} from '@atproto/api'
|
import {type AppBskyGraphDefs} from '@atproto/api'
|
||||||
|
import {type ModerationOpts} 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,5 +1,6 @@
|
|||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {type ChatBskyConvoDefs, type ModerationOpts} from '@atproto/api'
|
import {type ChatBskyConvoDefs} from '@atproto/api'
|
||||||
|
import {type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
import {useLingui} from '@lingui/react/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {MessageContextMenu} from '#/components/dms/MessageContextMenu'
|
import {MessageContextMenu} from '#/components/dms/MessageContextMenu'
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {useCallback, useRef, useState} from 'react'
|
import {useCallback, useRef, useState} from 'react'
|
||||||
import {Pressable, View} from 'react-native'
|
import {Pressable, View} from 'react-native'
|
||||||
import {type ChatBskyConvoDefs, type ModerationOpts} from '@atproto/api'
|
import {type ChatBskyConvoDefs} from '@atproto/api'
|
||||||
|
import {type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
import {plural} from '@lingui/core/macro'
|
import {plural} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {Fragment} from 'react'
|
import {Fragment} 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'
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {useCallback, useEffect} from 'react'
|
import {useCallback, useEffect} from 'react'
|
||||||
import {type ScrollView, View} from 'react-native'
|
import {type ScrollView, View} from 'react-native'
|
||||||
import Animated, {useAnimatedRef, useSharedValue} from 'react-native-reanimated'
|
import Animated, {useAnimatedRef, useSharedValue} from 'react-native-reanimated'
|
||||||
import {moderateProfile} from '@atproto/api'
|
import {moderateProfile} from '@bsky.app/sdk/moderation'
|
||||||
import {useLingui} from '@lingui/react/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {HITSLOP_10} from '#/lib/constants'
|
import {HITSLOP_10} from '#/lib/constants'
|
||||||
@@ -15,6 +15,7 @@ import {TimesLarge_Stroke2_Corner0_Rounded as XIcon} from '#/components/icons/Ti
|
|||||||
import * as ProfileCard from '#/components/ProfileCard'
|
import * as ProfileCard from '#/components/ProfileCard'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
testID?: string
|
testID?: string
|
||||||
@@ -89,7 +90,8 @@ function Tab({
|
|||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
|
|
||||||
const moderation = moderateProfile(profile, moderationOpts!)
|
// TODO(phase4): drop toLex once profile prop emits #/lexicons views
|
||||||
|
const moderation = moderateProfile(toLex(profile), moderationOpts!)
|
||||||
const displayName = sanitizeDisplayName(
|
const displayName = sanitizeDisplayName(
|
||||||
profile.displayName || sanitizeHandle(profile.handle),
|
profile.displayName || sanitizeHandle(profile.handle),
|
||||||
moderation.ui('displayName'),
|
moderation.ui('displayName'),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {memo, useCallback} from 'react'
|
import {memo, useCallback} from 'react'
|
||||||
import {Keyboard, View} from 'react-native'
|
import {Keyboard, View} from 'react-native'
|
||||||
import {type ModerationCause} from '@atproto/api'
|
import {type ModerationCause} 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'
|
||||||
import {useQueryClient} from '@tanstack/react-query'
|
import {useQueryClient} from '@tanstack/react-query'
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
useState,
|
useState,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
import {LayoutAnimation, type TextInput, View} from 'react-native'
|
import {LayoutAnimation, type TextInput, View} from 'react-native'
|
||||||
import {moderateProfile, type ModerationOpts} from '@atproto/api'
|
import {moderateProfile, type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
import {Plural, Trans, useLingui} from '@lingui/react/macro'
|
import {Plural, Trans, useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {MAX_GROUP_NAME_GRAPHEME_LENGTH} from '#/lib/constants'
|
import {MAX_GROUP_NAME_GRAPHEME_LENGTH} from '#/lib/constants'
|
||||||
@@ -54,6 +54,7 @@ import {Text} from '#/components/Typography'
|
|||||||
import {useAgeAssurance} from '#/ageAssurance'
|
import {useAgeAssurance} from '#/ageAssurance'
|
||||||
import {IS_NATIVE, IS_WEB} from '#/env'
|
import {IS_NATIVE, IS_WEB} from '#/env'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
|
|
||||||
type NewGroupChatItem = {
|
type NewGroupChatItem = {
|
||||||
type: 'newGroupChat'
|
type: 'newGroupChat'
|
||||||
@@ -1070,7 +1071,8 @@ function DefaultProfileCard({
|
|||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const enabled = canBeMessaged(profile)
|
const enabled = canBeMessaged(profile)
|
||||||
const moderation = moderateProfile(profile, moderationOpts)
|
// TODO(phase4): drop toLex once profile prop emits #/lexicons views
|
||||||
|
const moderation = moderateProfile(toLex(profile), moderationOpts)
|
||||||
const handle = sanitizeHandle(profile.handle, '@')
|
const handle = sanitizeHandle(profile.handle, '@')
|
||||||
const displayName = sanitizeDisplayName(
|
const displayName = sanitizeDisplayName(
|
||||||
profile.displayName || sanitizeHandle(profile.handle),
|
profile.displayName || sanitizeHandle(profile.handle),
|
||||||
|
|||||||
@@ -2,11 +2,9 @@ import {memo, useCallback} from 'react'
|
|||||||
import {Platform} from 'react-native'
|
import {Platform} from 'react-native'
|
||||||
import {type GestureType} from 'react-native-gesture-handler'
|
import {type GestureType} from 'react-native-gesture-handler'
|
||||||
import * as Clipboard from 'expo-clipboard'
|
import * as Clipboard from 'expo-clipboard'
|
||||||
import {
|
import {type ChatBskyConvoDefs} from '@atproto/api'
|
||||||
type ChatBskyConvoDefs,
|
import {type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
type ModerationOpts,
|
import {RichText} from '@bsky.app/sdk/richtext'
|
||||||
RichText,
|
|
||||||
} 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'
|
||||||
|
|
||||||
@@ -31,6 +29,7 @@ import * as Toast from '#/components/Toast'
|
|||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
import {IS_NATIVE} from '#/env'
|
import {IS_NATIVE} from '#/env'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
import {EmojiReactionPicker} from './EmojiReactionPicker'
|
import {EmojiReactionPicker} from './EmojiReactionPicker'
|
||||||
import {canReact, hasReachedReactionLimit} from './util'
|
import {canReact, hasReachedReactionLimit} from './util'
|
||||||
|
|
||||||
@@ -88,7 +87,8 @@ export let MessageContextMenu = ({
|
|||||||
const str = richTextToString(
|
const str = richTextToString(
|
||||||
new RichText({
|
new RichText({
|
||||||
text: message.text,
|
text: message.text,
|
||||||
facets: message.facets,
|
// TODO(phase4): drop toLex once the message producer emits #/lexicons facets
|
||||||
|
facets: toLex(message.facets),
|
||||||
}),
|
}),
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ import {
|
|||||||
type ChatBskyActorDefs,
|
type ChatBskyActorDefs,
|
||||||
ChatBskyConvoDefs,
|
ChatBskyConvoDefs,
|
||||||
ChatBskyEmbedJoinLink,
|
ChatBskyEmbedJoinLink,
|
||||||
moderateProfile,
|
|
||||||
RichText as RichTextAPI,
|
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
import {moderateProfile} from '@bsky.app/sdk/moderation'
|
||||||
|
import {RichText as RichTextAPI} from '@bsky.app/sdk/richtext'
|
||||||
import {plural} from '@lingui/core/macro'
|
import {plural} from '@lingui/core/macro'
|
||||||
import {Trans, useLingui} from '@lingui/react/macro'
|
import {Trans, useLingui} from '@lingui/react/macro'
|
||||||
import {useQueryClient} from '@tanstack/react-query'
|
import {useQueryClient} from '@tanstack/react-query'
|
||||||
@@ -58,6 +58,7 @@ import * as ProfileCard from '#/components/ProfileCard'
|
|||||||
import * as Prompt from '#/components/Prompt'
|
import * as Prompt from '#/components/Prompt'
|
||||||
import {RichText} from '#/components/RichText'
|
import {RichText} from '#/components/RichText'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
import {DateDivider} from './DateDivider'
|
import {DateDivider} from './DateDivider'
|
||||||
import {MessageItemEmbed} from './MessageItemEmbed'
|
import {MessageItemEmbed} from './MessageItemEmbed'
|
||||||
import {MessageItemInviteEmbed} from './MessageItemInviteEmbed'
|
import {MessageItemInviteEmbed} from './MessageItemInviteEmbed'
|
||||||
@@ -335,7 +336,9 @@ let MessageItem = ({
|
|||||||
size={AVATAR_SIZE}
|
size={AVATAR_SIZE}
|
||||||
type={profile.associated?.labeler ? 'labeler' : 'user'}
|
type={profile.associated?.labeler ? 'labeler' : 'user'}
|
||||||
onBeforePress={() => unstableCacheProfileView(queryClient, profile)}
|
onBeforePress={() => unstableCacheProfileView(queryClient, profile)}
|
||||||
moderation={moderateProfile(profile, moderationOpts).ui('avatar')}
|
moderation={moderateProfile(toLex(profile), moderationOpts).ui(
|
||||||
|
'avatar',
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<ProfileCard.AvatarPlaceholder size={AVATAR_SIZE} />
|
<ProfileCard.AvatarPlaceholder size={AVATAR_SIZE} />
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {useCallback, useMemo} from 'react'
|
import {useCallback, useMemo} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {type ModerationDecision} from '@atproto/api'
|
import {type ModerationDecision} from '@bsky.app/sdk/moderation'
|
||||||
import {Trans, useLingui} from '@lingui/react/macro'
|
import {Trans, useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {useMemo} from 'react'
|
import {useMemo} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {moderateProfile, type ModerationOpts} from '@atproto/api'
|
import {moderateProfile, type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
import {useLingui} from '@lingui/react/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {createSanitizedDisplayName} from '#/lib/moderation/create-sanitized-display-name'
|
import {createSanitizedDisplayName} from '#/lib/moderation/create-sanitized-display-name'
|
||||||
@@ -21,6 +21,7 @@ import {Link} from '#/components/Link'
|
|||||||
import {ProfileBadges} from '#/components/ProfileBadges'
|
import {ProfileBadges} from '#/components/ProfileBadges'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {IS_LIQUID_GLASS} from '#/env'
|
import {IS_LIQUID_GLASS} from '#/env'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
import {type ConvoWithDetails} from './util'
|
import {type ConvoWithDetails} from './util'
|
||||||
|
|
||||||
const PFP_SIZE = 40
|
const PFP_SIZE = 40
|
||||||
@@ -85,7 +86,8 @@ function ProfileHeaderReady({
|
|||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const profile = useProfileShadow(convo.primaryMember)
|
const profile = useProfileShadow(convo.primaryMember)
|
||||||
|
|
||||||
const moderation = moderateProfile(profile, moderationOpts)
|
// TODO(phase4): drop toLex once useProfileShadow emits #/lexicons views
|
||||||
|
const moderation = moderateProfile(toLex(profile), moderationOpts)
|
||||||
|
|
||||||
const blockInfo = useMemo(() => {
|
const blockInfo = useMemo(() => {
|
||||||
const modui = moderation.ui('profileView')
|
const modui = moderation.ui('profileView')
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {moderateProfile, type ModerationOpts} from '@atproto/api'
|
import {moderateProfile, type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
import {Trans} from '@lingui/react/macro'
|
import {Trans} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||||
@@ -10,6 +10,7 @@ import * as Toggle from '#/components/forms/Toggle'
|
|||||||
import * as ProfileCard from '#/components/ProfileCard'
|
import * as ProfileCard from '#/components/ProfileCard'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
|
|
||||||
export function GroupChatProfileCard({
|
export function GroupChatProfileCard({
|
||||||
profile,
|
profile,
|
||||||
@@ -20,7 +21,8 @@ export function GroupChatProfileCard({
|
|||||||
}) {
|
}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const enabled = canBeAddedToGroup(profile)
|
const enabled = canBeAddedToGroup(profile)
|
||||||
const moderation = moderateProfile(profile, moderationOpts)
|
// TODO(phase4): drop toLex once profile prop emits #/lexicons views
|
||||||
|
const moderation = moderateProfile(toLex(profile), moderationOpts)
|
||||||
const handle = sanitizeHandle(profile.handle, '@')
|
const handle = sanitizeHandle(profile.handle, '@')
|
||||||
const displayName = sanitizeDisplayName(
|
const displayName = sanitizeDisplayName(
|
||||||
profile.displayName || sanitizeHandle(profile.handle),
|
profile.displayName || sanitizeHandle(profile.handle),
|
||||||
|
|||||||
+12
-27
@@ -1,10 +1,6 @@
|
|||||||
import {
|
import {type ChatBskyActorDefs, type ChatBskyConvoDefs} from '@atproto/api'
|
||||||
type $Typed,
|
import {type $Typed} from '@atproto/lex'
|
||||||
ChatBskyActorDefs,
|
import {moderateProfile, type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||||
ChatBskyConvoDefs,
|
|
||||||
moderateProfile,
|
|
||||||
type ModerationOpts,
|
|
||||||
} from '@atproto/api'
|
|
||||||
|
|
||||||
import {EMOJI_REACTION_LIMIT} from '#/lib/constants'
|
import {EMOJI_REACTION_LIMIT} from '#/lib/constants'
|
||||||
import {isBlockedOrBlocking} from '#/lib/moderation/blocked-and-muted'
|
import {isBlockedOrBlocking} from '#/lib/moderation/blocked-and-muted'
|
||||||
@@ -13,6 +9,7 @@ import {type Shadow} from '#/state/cache/profile-shadow'
|
|||||||
import {type ConvoState, ConvoStatus} from '#/state/messages/convo/types'
|
import {type ConvoState, ConvoStatus} from '#/state/messages/convo/types'
|
||||||
import {platform} from '#/alf'
|
import {platform} from '#/alf'
|
||||||
import {type ReportSubject} from '#/components/moderation/ReportDialog/types'
|
import {type ReportSubject} from '#/components/moderation/ReportDialog/types'
|
||||||
|
import {chat} from '#/lexicons'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
export const MESSAGE_GAP_THRESHOLD_MS = 60 * 60 * 1000
|
export const MESSAGE_GAP_THRESHOLD_MS = 60 * 60 * 1000
|
||||||
@@ -158,7 +155,10 @@ export function canReact({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (primaryMember && moderationOpts) {
|
if (primaryMember && moderationOpts) {
|
||||||
const moderation = moderateProfile(primaryMember, moderationOpts)
|
const moderation = moderateProfile(
|
||||||
|
bsky.toLex(primaryMember),
|
||||||
|
moderationOpts,
|
||||||
|
)
|
||||||
if (convoState.convo.kind === 'direct') {
|
if (convoState.convo.kind === 'direct') {
|
||||||
// Either direction (blocking or blocked-by) hides reactions in 1-1s
|
// Either direction (blocking or blocked-by) hides reactions in 1-1s
|
||||||
if (moderation.blocked) return false
|
if (moderation.blocked) return false
|
||||||
@@ -206,21 +206,11 @@ export function parseConvoView(
|
|||||||
convoView: ChatBskyConvoDefs.ConvoView,
|
convoView: ChatBskyConvoDefs.ConvoView,
|
||||||
ownDid: string | undefined,
|
ownDid: string | undefined,
|
||||||
): ConvoWithDetails | null {
|
): ConvoWithDetails | null {
|
||||||
if (
|
if (bsky.isType(chat.bsky.convo.defs.groupConvo, convoView.kind)) {
|
||||||
bsky.dangerousIsType<ChatBskyConvoDefs.GroupConvo>(
|
|
||||||
convoView.kind,
|
|
||||||
ChatBskyConvoDefs.isGroupConvo,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
let owner: GroupConvoMember | undefined = undefined
|
let owner: GroupConvoMember | undefined = undefined
|
||||||
|
|
||||||
for (const member of convoView.members) {
|
for (const member of convoView.members) {
|
||||||
if (
|
if (bsky.isType(chat.bsky.actor.defs.groupConvoMember, member.kind)) {
|
||||||
bsky.dangerousIsType<ChatBskyActorDefs.GroupConvoMember>(
|
|
||||||
member.kind,
|
|
||||||
ChatBskyActorDefs.isGroupConvoMember,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
if (member.kind.role === 'owner') {
|
if (member.kind.role === 'owner') {
|
||||||
// have to do a type assertion here
|
// have to do a type assertion here
|
||||||
// this works: {...member, kind: member.kind}
|
// this works: {...member, kind: member.kind}
|
||||||
@@ -242,12 +232,7 @@ export function parseConvoView(
|
|||||||
primaryMember: owner,
|
primaryMember: owner,
|
||||||
members: convoView.members as Array<GroupConvoMember>,
|
members: convoView.members as Array<GroupConvoMember>,
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (bsky.isType(chat.bsky.convo.defs.directConvo, convoView.kind)) {
|
||||||
bsky.dangerousIsType<ChatBskyConvoDefs.DirectConvo>(
|
|
||||||
convoView.kind,
|
|
||||||
ChatBskyConvoDefs.isDirectConvo,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
const otherUser = convoView.members.find(m => m.did !== ownDid)
|
const otherUser = convoView.members.find(m => m.did !== ownDid)
|
||||||
|
|
||||||
if (!otherUser) {
|
if (!otherUser) {
|
||||||
@@ -290,7 +275,7 @@ export function getConvoReportSubject(
|
|||||||
|
|
||||||
const lastMessage = convo.view.lastMessage
|
const lastMessage = convo.view.lastMessage
|
||||||
const reportableMessage =
|
const reportableMessage =
|
||||||
ChatBskyConvoDefs.isMessageView(lastMessage) &&
|
bsky.isType(chat.bsky.convo.defs.messageView, lastMessage) &&
|
||||||
lastMessage.sender?.did !== ownDid
|
lastMessage.sender?.did !== ownDid
|
||||||
? lastMessage
|
? lastMessage
|
||||||
: null
|
: null
|
||||||
|
|||||||
@@ -1,16 +1,10 @@
|
|||||||
import {
|
import {type AppBskyFeedDefs} from '@atproto/api'
|
||||||
AppBskyEmbedGallery,
|
import {type ModerationCause, type ModerationUI} from '@bsky.app/sdk/moderation'
|
||||||
AppBskyEmbedImages,
|
|
||||||
AppBskyEmbedRecordWithMedia,
|
|
||||||
type AppBskyFeedDefs,
|
|
||||||
AppBskyFeedPost,
|
|
||||||
type ModerationCause,
|
|
||||||
type ModerationUI,
|
|
||||||
} from '@atproto/api'
|
|
||||||
|
|
||||||
import {unique} from '#/lib/moderation'
|
import {unique} from '#/lib/moderation'
|
||||||
import {type AppModerationCause} from '#/components/Pills'
|
import {type AppModerationCause} from '#/components/Pills'
|
||||||
import {Features, features} from '#/analytics/features'
|
import {Features, features} from '#/analytics/features'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
export const POST_META_NO_CONTENT_OFFSET = {paddingTop: 10}
|
export const POST_META_NO_CONTENT_OFFSET = {paddingTop: 10}
|
||||||
@@ -28,12 +22,7 @@ export function maybeApplyGalleryOffsetStyles(
|
|||||||
additionalCauses?: ModerationCause[] | AppModerationCause[]
|
additionalCauses?: ModerationCause[] | AppModerationCause[]
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
if (
|
if (!bsky.isType(app.bsky.feed.post, post.record)) {
|
||||||
!bsky.dangerousIsType<AppBskyFeedPost.Record>(
|
|
||||||
post.record,
|
|
||||||
AppBskyFeedPost.isRecord,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,24 +37,10 @@ export function maybeApplyGalleryOffsetStyles(
|
|||||||
* First check if we even have images
|
* First check if we even have images
|
||||||
*/
|
*/
|
||||||
const embed = post.record.embed
|
const embed = post.record.embed
|
||||||
const isImageEmbed =
|
const isImageEmbed = embed && bsky.isType(app.bsky.embed.images, embed)
|
||||||
embed &&
|
const isGalleryEmbed = embed && bsky.isType(app.bsky.embed.gallery, embed)
|
||||||
bsky.dangerousIsType<AppBskyEmbedImages.Main>(
|
|
||||||
embed,
|
|
||||||
AppBskyEmbedImages.isMain,
|
|
||||||
)
|
|
||||||
const isGalleryEmbed =
|
|
||||||
embed &&
|
|
||||||
bsky.dangerousIsType<AppBskyEmbedGallery.Main>(
|
|
||||||
embed,
|
|
||||||
AppBskyEmbedGallery.isMain,
|
|
||||||
)
|
|
||||||
const isRecordWithMedia =
|
const isRecordWithMedia =
|
||||||
embed &&
|
embed && bsky.isType(app.bsky.embed.recordWithMedia, embed)
|
||||||
bsky.dangerousIsType<AppBskyEmbedRecordWithMedia.Main>(
|
|
||||||
embed,
|
|
||||||
AppBskyEmbedRecordWithMedia.isMain,
|
|
||||||
)
|
|
||||||
let hasImages = false
|
let hasImages = false
|
||||||
if (isImageEmbed) {
|
if (isImageEmbed) {
|
||||||
if (!isPostGalleryEmbedEnabled) return
|
if (!isPostGalleryEmbedEnabled) return
|
||||||
@@ -79,22 +54,12 @@ export function maybeApplyGalleryOffsetStyles(
|
|||||||
hasImages = true
|
hasImages = true
|
||||||
}
|
}
|
||||||
if (isRecordWithMedia) {
|
if (isRecordWithMedia) {
|
||||||
if (
|
if (bsky.isType(app.bsky.embed.images, embed.media)) {
|
||||||
bsky.dangerousIsType<AppBskyEmbedImages.Main>(
|
|
||||||
embed.media,
|
|
||||||
AppBskyEmbedImages.isMain,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
if (!isPostGalleryEmbedEnabled) return
|
if (!isPostGalleryEmbedEnabled) return
|
||||||
// one image, not a gallery
|
// one image, not a gallery
|
||||||
if (embed.media.images.length === 1) return
|
if (embed.media.images.length === 1) return
|
||||||
}
|
}
|
||||||
if (
|
if (bsky.isType(app.bsky.embed.gallery, embed.media)) {
|
||||||
bsky.dangerousIsType<AppBskyEmbedGallery.Main>(
|
|
||||||
embed.media,
|
|
||||||
AppBskyEmbedGallery.isMain,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
// single (or empty) gallery - no offset needed
|
// single (or empty) gallery - no offset needed
|
||||||
if (embed.media.items.length <= 1) return
|
if (embed.media.items.length <= 1) return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import {
|
|||||||
ChatBskyGroupDefs,
|
ChatBskyGroupDefs,
|
||||||
ChatBskyGroupRequestJoin,
|
ChatBskyGroupRequestJoin,
|
||||||
ChatBskyGroupWithdrawJoinRequest,
|
ChatBskyGroupWithdrawJoinRequest,
|
||||||
moderateProfile,
|
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
import {moderateProfile} from '@bsky.app/sdk/moderation'
|
||||||
import {Plural, Trans, useLingui} from '@lingui/react/macro'
|
import {Plural, Trans, useLingui} from '@lingui/react/macro'
|
||||||
import {useNavigation} from '@react-navigation/native'
|
import {useNavigation} from '@react-navigation/native'
|
||||||
import {useQueryClient} from '@tanstack/react-query'
|
import {useQueryClient} from '@tanstack/react-query'
|
||||||
@@ -49,6 +49,7 @@ import {Loader} from '#/components/Loader'
|
|||||||
import * as Toast from '#/components/Toast'
|
import * as Toast from '#/components/Toast'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
import {ProfileBadges} from '../ProfileBadges'
|
import {ProfileBadges} from '../ProfileBadges'
|
||||||
|
|
||||||
export function GroupChatJoinDialog() {
|
export function GroupChatJoinDialog() {
|
||||||
@@ -406,9 +407,11 @@ function GroupChatJoinDialogContent({code}: {code?: string}) {
|
|||||||
{createSanitizedDisplayName(
|
{createSanitizedDisplayName(
|
||||||
joinLinkPreview.owner,
|
joinLinkPreview.owner,
|
||||||
true,
|
true,
|
||||||
moderateProfile(joinLinkPreview.owner, moderationOpts).ui(
|
// TODO(phase4): drop toLex once join link preview emits #/lexicons views
|
||||||
'displayName',
|
moderateProfile(
|
||||||
),
|
toLex(joinLinkPreview.owner),
|
||||||
|
moderationOpts,
|
||||||
|
).ui('displayName'),
|
||||||
)}
|
)}
|
||||||
</InlineLinkText>
|
</InlineLinkText>
|
||||||
</Trans>
|
</Trans>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {useCallback, useEffect, useMemo} from 'react'
|
import {useCallback, useEffect, useMemo} from 'react'
|
||||||
import {ScrollView, View} from 'react-native'
|
import {ScrollView, View} from 'react-native'
|
||||||
import {AppBskyEmbedVideo, AtUri} from '@atproto/api'
|
import {AppBskyEmbedVideo} from '@atproto/api'
|
||||||
|
import {AtUri} from '@atproto/syntax'
|
||||||
import {Trans, useLingui} from '@lingui/react/macro'
|
import {Trans, useLingui} from '@lingui/react/macro'
|
||||||
import {useQueryClient} from '@tanstack/react-query'
|
import {useQueryClient} from '@tanstack/react-query'
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import {useState} from 'react'
|
import {useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {type ComAtprotoLabelDefs, ToolsOzoneReportDefs} from '@atproto/api'
|
import {type Service} from '@atproto/lex-client'
|
||||||
import {XRPCError} 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'
|
||||||
@@ -11,8 +10,9 @@ import {useLabelSubject} from '#/lib/moderation'
|
|||||||
import {useLabelInfo} from '#/lib/moderation/useLabelInfo'
|
import {useLabelInfo} from '#/lib/moderation/useLabelInfo'
|
||||||
import {makeProfileLink} from '#/lib/routes/links'
|
import {makeProfileLink} from '#/lib/routes/links'
|
||||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
|
import {getErrorName, isXrpcError} from '#/lib/xrpc-error'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {useAgent} from '#/state/session'
|
import {usePdsClient} from '#/state/session'
|
||||||
import {atoms as a, useBreakpoints} from '#/alf'
|
import {atoms as a, useBreakpoints} from '#/alf'
|
||||||
import {Admonition} from '#/components/Admonition'
|
import {Admonition} from '#/components/Admonition'
|
||||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
@@ -22,13 +22,15 @@ import {Loader} from '#/components/Loader'
|
|||||||
import * as Toast from '#/components/Toast'
|
import * as Toast from '#/components/Toast'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {IS_ANDROID} from '#/env'
|
import {IS_ANDROID} from '#/env'
|
||||||
|
import {com, tools} from '#/lexicons'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
|
|
||||||
export function AppealForm({
|
export function AppealForm({
|
||||||
label,
|
label,
|
||||||
control,
|
control,
|
||||||
onPressBack,
|
onPressBack,
|
||||||
}: {
|
}: {
|
||||||
label: ComAtprotoLabelDefs.Label
|
label: com.atproto.label.defs.Label
|
||||||
control: Dialog.DialogOuterProps['control']
|
control: Dialog.DialogOuterProps['control']
|
||||||
onPressBack: () => void
|
onPressBack: () => void
|
||||||
}) {
|
}) {
|
||||||
@@ -38,7 +40,7 @@ export function AppealForm({
|
|||||||
const [details, setDetails] = useState('')
|
const [details, setDetails] = useState('')
|
||||||
const {subject} = useLabelSubject({label})
|
const {subject} = useLabelSubject({label})
|
||||||
const isAccountReport = 'did' in subject
|
const isAccountReport = 'did' in subject
|
||||||
const agent = useAgent()
|
const pdsClient = usePdsClient()
|
||||||
const sourceName = labeler
|
const sourceName = labeler
|
||||||
? sanitizeHandle(labeler.creator.handle, '@')
|
? sanitizeHandle(labeler.creator.handle, '@')
|
||||||
: label.src
|
: label.src
|
||||||
@@ -49,25 +51,23 @@ export function AppealForm({
|
|||||||
const $type = !isAccountReport
|
const $type = !isAccountReport
|
||||||
? 'com.atproto.repo.strongRef'
|
? 'com.atproto.repo.strongRef'
|
||||||
: 'com.atproto.admin.defs#repoRef'
|
: 'com.atproto.admin.defs#repoRef'
|
||||||
await agent.createModerationReport(
|
await pdsClient.call(
|
||||||
{
|
com.atproto.moderation.createReport,
|
||||||
reasonType: ToolsOzoneReportDefs.REASONAPPEAL,
|
toLex<com.atproto.moderation.createReport.$InputBody>({
|
||||||
|
reasonType: tools.ozone.report.defs.reasonAppeal.value,
|
||||||
subject: {
|
subject: {
|
||||||
$type,
|
$type,
|
||||||
...subject,
|
...subject,
|
||||||
},
|
},
|
||||||
reason: details,
|
reason: details,
|
||||||
},
|
}),
|
||||||
{
|
{
|
||||||
encoding: 'application/json',
|
service: `${label.src}#atproto_labeler` as Service,
|
||||||
headers: {
|
|
||||||
'atproto-proxy': `${label.src}#atproto_labeler`,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
onError: err => {
|
onError: err => {
|
||||||
if (err instanceof XRPCError && err.error === 'AlreadyAppealed') {
|
if (isXrpcError(err) && getErrorName(err) === 'AlreadyAppealed') {
|
||||||
setError(
|
setError(
|
||||||
_(
|
_(
|
||||||
msg`You've already appealed this label and it's being reviewed by our moderation team.`,
|
msg`You've already appealed this label and it's being reviewed by our moderation team.`,
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|
||||||
@@ -20,6 +16,7 @@ import {
|
|||||||
useLabelsOnMeDialogControl,
|
useLabelsOnMeDialogControl,
|
||||||
} from '#/components/moderation/LabelsOnMeDialog'
|
} from '#/components/moderation/LabelsOnMeDialog'
|
||||||
import * as Pills from '#/components/Pills'
|
import * as Pills from '#/components/Pills'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
|
|
||||||
export function PostAlerts({
|
export function PostAlerts({
|
||||||
post,
|
post,
|
||||||
@@ -71,7 +68,8 @@ export function PostAlerts({
|
|||||||
*/
|
*/
|
||||||
const shownCauses = [...alerts, ...informs, ...modui.blurs]
|
const shownCauses = [...alerts, ...informs, ...modui.blurs]
|
||||||
const additionalLabels = filterUserFacingLabels(
|
const additionalLabels = filterUserFacingLabels(
|
||||||
allLabels,
|
// TODO(phase4): drop toLex once PostView labels are #/lexicons-typed
|
||||||
|
toLex(allLabels),
|
||||||
currentAccount?.did,
|
currentAccount?.did,
|
||||||
).filter(label =>
|
).filter(label =>
|
||||||
shownCauses.every(
|
shownCauses.every(
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
import {
|
import {type Service} from '@atproto/lex-client'
|
||||||
type $Typed,
|
|
||||||
type ChatBskyConvoDefs,
|
|
||||||
type ComAtprotoModerationCreateReport,
|
|
||||||
} 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 {useMutation} from '@tanstack/react-query'
|
import {useMutation} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {useAgent} from '#/state/session'
|
import {usePdsClient} from '#/state/session'
|
||||||
|
import {com} from '#/lexicons'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
import {NEW_TO_OLD_REASONS_MAP} from './const'
|
import {NEW_TO_OLD_REASONS_MAP} from './const'
|
||||||
import {type ReportState} from './state'
|
import {type ReportState} from './state'
|
||||||
import {type ParsedReportSubject} from './types'
|
import {type ParsedReportSubject} from './types'
|
||||||
|
|
||||||
|
type CreateReportBody = com.atproto.moderation.createReport.$InputBody
|
||||||
|
|
||||||
export function useSubmitReportMutation() {
|
export function useSubmitReportMutation() {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const agent = useAgent()
|
const pdsClient = usePdsClient()
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
async mutationFn({
|
async mutationFn({
|
||||||
@@ -52,13 +52,17 @@ export function useSubmitReportMutation() {
|
|||||||
reasonType = backwardsCompatibleReasonType
|
reasonType = backwardsCompatibleReasonType
|
||||||
}
|
}
|
||||||
|
|
||||||
let report:
|
/*
|
||||||
| ComAtprotoModerationCreateReport.InputSchema
|
* The generated `createReport` subject union only declares repoRef and
|
||||||
| (Omit<ComAtprotoModerationCreateReport.InputSchema, 'subject'> & {
|
* strongRef with branded did/uri strings; chat subjects (message/convo
|
||||||
subject:
|
* refs) are accepted on the wire but not in the lexicon, and the subject
|
||||||
| $Typed<ChatBskyConvoDefs.MessageRef>
|
* ids we hold here are plain strings. We build the body against a loose
|
||||||
| $Typed<ChatBskyConvoDefs.ConvoRef>
|
* subject shape and `toLex` it to the schema body at the call boundary
|
||||||
})
|
* (matching the old widened-InputSchema shape).
|
||||||
|
*/
|
||||||
|
let report: Omit<CreateReportBody, 'subject'> & {
|
||||||
|
subject: {$type: string} & Record<string, unknown>
|
||||||
|
}
|
||||||
|
|
||||||
switch (subject.type) {
|
switch (subject.type) {
|
||||||
case 'account': {
|
case 'account': {
|
||||||
@@ -123,12 +127,19 @@ export function useSubmitReportMutation() {
|
|||||||
report,
|
report,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
await agent.createModerationReport(report, {
|
/*
|
||||||
encoding: 'application/json',
|
* Route the report through the selected labeler's moderation service
|
||||||
headers: {
|
* via the `atproto-proxy` header, which lex-client sets from the
|
||||||
'atproto-proxy': `${labeler.creator.did}#atproto_labeler`,
|
* per-call `service` option (previously an explicit header on the
|
||||||
|
* bridge agent).
|
||||||
|
*/
|
||||||
|
await pdsClient.call(
|
||||||
|
com.atproto.moderation.createReport,
|
||||||
|
toLex<CreateReportBody>(report),
|
||||||
|
{
|
||||||
|
service: `${labeler.creator.did}#atproto_labeler` as Service,
|
||||||
},
|
},
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import {
|
|
||||||
ComAtprotoModerationDefs as RootReportDefs,
|
|
||||||
ToolsOzoneReportDefs as OzoneReportDefs,
|
|
||||||
} from '@atproto/api'
|
|
||||||
|
|
||||||
import {type ParsedReportSubject} from '#/components/moderation/ReportDialog/types'
|
import {type ParsedReportSubject} from '#/components/moderation/ReportDialog/types'
|
||||||
|
import {com, tools} from '#/lexicons'
|
||||||
|
|
||||||
|
const OzoneReportDefs = tools.ozone.report.defs
|
||||||
|
const RootReportDefs = com.atproto.moderation.defs
|
||||||
|
|
||||||
|
type OzoneReasonType = tools.ozone.report.defs.ReasonType
|
||||||
|
type RootReasonType = com.atproto.moderation.defs.ReasonType
|
||||||
|
|
||||||
export const DMCA_LINK = 'https://bsky.social/about/support/copyright'
|
export const DMCA_LINK = 'https://bsky.social/about/support/copyright'
|
||||||
export const SUPPORT_PAGE = 'https://bsky.social/about/support'
|
export const SUPPORT_PAGE = 'https://bsky.social/about/support'
|
||||||
@@ -17,60 +19,87 @@ export const NEW_TO_OLD_REASON_MAPPING: Record<string, string> = {}
|
|||||||
* Matches the mapping defined in the Ozone codebase:
|
* Matches the mapping defined in the Ozone codebase:
|
||||||
* @see https://github.com/bluesky-social/atproto/blob/4c15fb47cec26060bff2e710e95869a90c9d7fdd/packages/ozone/src/mod-service/profile.ts#L16-L64
|
* @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<
|
export const NEW_TO_OLD_REASONS_MAP: Record<OzoneReasonType, RootReasonType> = {
|
||||||
OzoneReportDefs.ReasonType,
|
[OzoneReportDefs.reasonAppeal.value]: RootReportDefs.reasonAppeal.value,
|
||||||
RootReportDefs.ReasonType
|
[OzoneReportDefs.reasonOther.value]: RootReportDefs.reasonOther.value,
|
||||||
> = {
|
|
||||||
[OzoneReportDefs.REASONAPPEAL]: RootReportDefs.REASONAPPEAL,
|
|
||||||
[OzoneReportDefs.REASONOTHER]: RootReportDefs.REASONOTHER,
|
|
||||||
|
|
||||||
[OzoneReportDefs.REASONVIOLENCEANIMAL]: RootReportDefs.REASONVIOLATION,
|
[OzoneReportDefs.reasonViolenceAnimal.value]:
|
||||||
[OzoneReportDefs.REASONVIOLENCETHREATS]: RootReportDefs.REASONVIOLATION,
|
RootReportDefs.reasonViolation.value,
|
||||||
[OzoneReportDefs.REASONVIOLENCEGRAPHICCONTENT]:
|
[OzoneReportDefs.reasonViolenceThreats.value]:
|
||||||
RootReportDefs.REASONVIOLATION,
|
RootReportDefs.reasonViolation.value,
|
||||||
[OzoneReportDefs.REASONVIOLENCEGLORIFICATION]: RootReportDefs.REASONVIOLATION,
|
[OzoneReportDefs.reasonViolenceGraphicContent.value]:
|
||||||
[OzoneReportDefs.REASONVIOLENCEEXTREMISTCONTENT]:
|
RootReportDefs.reasonViolation.value,
|
||||||
RootReportDefs.REASONVIOLATION,
|
[OzoneReportDefs.reasonViolenceGlorification.value]:
|
||||||
[OzoneReportDefs.REASONVIOLENCETRAFFICKING]: RootReportDefs.REASONVIOLATION,
|
RootReportDefs.reasonViolation.value,
|
||||||
[OzoneReportDefs.REASONVIOLENCEOTHER]: RootReportDefs.REASONVIOLATION,
|
[OzoneReportDefs.reasonViolenceExtremistContent.value]:
|
||||||
|
RootReportDefs.reasonViolation.value,
|
||||||
|
[OzoneReportDefs.reasonViolenceTrafficking.value]:
|
||||||
|
RootReportDefs.reasonViolation.value,
|
||||||
|
[OzoneReportDefs.reasonViolenceOther.value]:
|
||||||
|
RootReportDefs.reasonViolation.value,
|
||||||
|
|
||||||
[OzoneReportDefs.REASONSEXUALABUSECONTENT]: RootReportDefs.REASONSEXUAL,
|
[OzoneReportDefs.reasonSexualAbuseContent.value]:
|
||||||
[OzoneReportDefs.REASONSEXUALNCII]: RootReportDefs.REASONSEXUAL,
|
RootReportDefs.reasonSexual.value,
|
||||||
[OzoneReportDefs.REASONSEXUALDEEPFAKE]: RootReportDefs.REASONSEXUAL,
|
[OzoneReportDefs.reasonSexualNCII.value]: RootReportDefs.reasonSexual.value,
|
||||||
[OzoneReportDefs.REASONSEXUALANIMAL]: RootReportDefs.REASONSEXUAL,
|
[OzoneReportDefs.reasonSexualDeepfake.value]:
|
||||||
[OzoneReportDefs.REASONSEXUALUNLABELED]: RootReportDefs.REASONSEXUAL,
|
RootReportDefs.reasonSexual.value,
|
||||||
[OzoneReportDefs.REASONSEXUALOTHER]: RootReportDefs.REASONSEXUAL,
|
[OzoneReportDefs.reasonSexualAnimal.value]: RootReportDefs.reasonSexual.value,
|
||||||
|
[OzoneReportDefs.reasonSexualUnlabeled.value]:
|
||||||
|
RootReportDefs.reasonSexual.value,
|
||||||
|
[OzoneReportDefs.reasonSexualOther.value]: RootReportDefs.reasonSexual.value,
|
||||||
|
|
||||||
[OzoneReportDefs.REASONCHILDSAFETYCSAM]: RootReportDefs.REASONVIOLATION,
|
[OzoneReportDefs.reasonChildSafetyCSAM.value]:
|
||||||
[OzoneReportDefs.REASONCHILDSAFETYGROOM]: RootReportDefs.REASONVIOLATION,
|
RootReportDefs.reasonViolation.value,
|
||||||
[OzoneReportDefs.REASONCHILDSAFETYPRIVACY]: RootReportDefs.REASONVIOLATION,
|
[OzoneReportDefs.reasonChildSafetyGroom.value]:
|
||||||
[OzoneReportDefs.REASONCHILDSAFETYHARASSMENT]: RootReportDefs.REASONVIOLATION,
|
RootReportDefs.reasonViolation.value,
|
||||||
[OzoneReportDefs.REASONCHILDSAFETYOTHER]: RootReportDefs.REASONVIOLATION,
|
[OzoneReportDefs.reasonChildSafetyPrivacy.value]:
|
||||||
|
RootReportDefs.reasonViolation.value,
|
||||||
|
[OzoneReportDefs.reasonChildSafetyHarassment.value]:
|
||||||
|
RootReportDefs.reasonViolation.value,
|
||||||
|
[OzoneReportDefs.reasonChildSafetyOther.value]:
|
||||||
|
RootReportDefs.reasonViolation.value,
|
||||||
|
|
||||||
[OzoneReportDefs.REASONHARASSMENTTROLL]: RootReportDefs.REASONRUDE,
|
[OzoneReportDefs.reasonHarassmentTroll.value]:
|
||||||
[OzoneReportDefs.REASONHARASSMENTTARGETED]: RootReportDefs.REASONRUDE,
|
RootReportDefs.reasonRude.value,
|
||||||
[OzoneReportDefs.REASONHARASSMENTHATESPEECH]: RootReportDefs.REASONRUDE,
|
[OzoneReportDefs.reasonHarassmentTargeted.value]:
|
||||||
[OzoneReportDefs.REASONHARASSMENTDOXXING]: RootReportDefs.REASONRUDE,
|
RootReportDefs.reasonRude.value,
|
||||||
[OzoneReportDefs.REASONHARASSMENTOTHER]: RootReportDefs.REASONRUDE,
|
[OzoneReportDefs.reasonHarassmentHateSpeech.value]:
|
||||||
|
RootReportDefs.reasonRude.value,
|
||||||
|
[OzoneReportDefs.reasonHarassmentDoxxing.value]:
|
||||||
|
RootReportDefs.reasonRude.value,
|
||||||
|
[OzoneReportDefs.reasonHarassmentOther.value]:
|
||||||
|
RootReportDefs.reasonRude.value,
|
||||||
|
|
||||||
[OzoneReportDefs.REASONMISLEADINGBOT]: RootReportDefs.REASONMISLEADING,
|
[OzoneReportDefs.reasonMisleadingBot.value]:
|
||||||
[OzoneReportDefs.REASONMISLEADINGIMPERSONATION]:
|
RootReportDefs.reasonMisleading.value,
|
||||||
RootReportDefs.REASONMISLEADING,
|
[OzoneReportDefs.reasonMisleadingImpersonation.value]:
|
||||||
[OzoneReportDefs.REASONMISLEADINGSPAM]: RootReportDefs.REASONSPAM,
|
RootReportDefs.reasonMisleading.value,
|
||||||
[OzoneReportDefs.REASONMISLEADINGSCAM]: RootReportDefs.REASONMISLEADING,
|
[OzoneReportDefs.reasonMisleadingSpam.value]: RootReportDefs.reasonSpam.value,
|
||||||
[OzoneReportDefs.REASONMISLEADINGELECTIONS]: RootReportDefs.REASONMISLEADING,
|
[OzoneReportDefs.reasonMisleadingScam.value]:
|
||||||
[OzoneReportDefs.REASONMISLEADINGOTHER]: RootReportDefs.REASONMISLEADING,
|
RootReportDefs.reasonMisleading.value,
|
||||||
|
[OzoneReportDefs.reasonMisleadingElections.value]:
|
||||||
|
RootReportDefs.reasonMisleading.value,
|
||||||
|
[OzoneReportDefs.reasonMisleadingOther.value]:
|
||||||
|
RootReportDefs.reasonMisleading.value,
|
||||||
|
|
||||||
[OzoneReportDefs.REASONRULESITESECURITY]: RootReportDefs.REASONVIOLATION,
|
[OzoneReportDefs.reasonRuleSiteSecurity.value]:
|
||||||
[OzoneReportDefs.REASONRULEPROHIBITEDSALES]: RootReportDefs.REASONVIOLATION,
|
RootReportDefs.reasonViolation.value,
|
||||||
[OzoneReportDefs.REASONRULEBANEVASION]: RootReportDefs.REASONVIOLATION,
|
[OzoneReportDefs.reasonRuleProhibitedSales.value]:
|
||||||
[OzoneReportDefs.REASONRULEOTHER]: RootReportDefs.REASONVIOLATION,
|
RootReportDefs.reasonViolation.value,
|
||||||
|
[OzoneReportDefs.reasonRuleBanEvasion.value]:
|
||||||
|
RootReportDefs.reasonViolation.value,
|
||||||
|
[OzoneReportDefs.reasonRuleOther.value]: RootReportDefs.reasonViolation.value,
|
||||||
|
|
||||||
[OzoneReportDefs.REASONSELFHARMCONTENT]: RootReportDefs.REASONVIOLATION,
|
[OzoneReportDefs.reasonSelfHarmContent.value]:
|
||||||
[OzoneReportDefs.REASONSELFHARMED]: RootReportDefs.REASONVIOLATION,
|
RootReportDefs.reasonViolation.value,
|
||||||
[OzoneReportDefs.REASONSELFHARMSTUNTS]: RootReportDefs.REASONVIOLATION,
|
[OzoneReportDefs.reasonSelfHarmED.value]:
|
||||||
[OzoneReportDefs.REASONSELFHARMSUBSTANCES]: RootReportDefs.REASONVIOLATION,
|
RootReportDefs.reasonViolation.value,
|
||||||
[OzoneReportDefs.REASONSELFHARMOTHER]: RootReportDefs.REASONVIOLATION,
|
[OzoneReportDefs.reasonSelfHarmStunts.value]:
|
||||||
|
RootReportDefs.reasonViolation.value,
|
||||||
|
[OzoneReportDefs.reasonSelfHarmSubstances.value]:
|
||||||
|
RootReportDefs.reasonViolation.value,
|
||||||
|
[OzoneReportDefs.reasonSelfHarmOther.value]:
|
||||||
|
RootReportDefs.reasonViolation.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,42 +107,44 @@ export const NEW_TO_OLD_REASONS_MAP: Record<
|
|||||||
* @see https://github.com/bluesky-social/proposals/tree/main/0009-mod-report-granularity#backwards-compatibility
|
* @see https://github.com/bluesky-social/proposals/tree/main/0009-mod-report-granularity#backwards-compatibility
|
||||||
*/
|
*/
|
||||||
export const OLD_TO_NEW_REASONS_MAP: Record<
|
export const OLD_TO_NEW_REASONS_MAP: Record<
|
||||||
Exclude<RootReportDefs.ReasonType, OzoneReportDefs.ReasonType>,
|
Exclude<RootReasonType, OzoneReasonType>,
|
||||||
OzoneReportDefs.ReasonType
|
OzoneReasonType
|
||||||
> = {
|
> = {
|
||||||
[RootReportDefs.REASONSPAM]: [OzoneReportDefs.REASONMISLEADINGSPAM],
|
[RootReportDefs.reasonSpam.value]: OzoneReportDefs.reasonMisleadingSpam.value,
|
||||||
[RootReportDefs.REASONVIOLATION]: [OzoneReportDefs.REASONRULEOTHER],
|
[RootReportDefs.reasonViolation.value]: OzoneReportDefs.reasonRuleOther.value,
|
||||||
[RootReportDefs.REASONMISLEADING]: [OzoneReportDefs.REASONMISLEADINGOTHER],
|
[RootReportDefs.reasonMisleading.value]:
|
||||||
[RootReportDefs.REASONSEXUAL]: [OzoneReportDefs.REASONSEXUALUNLABELED],
|
OzoneReportDefs.reasonMisleadingOther.value,
|
||||||
[RootReportDefs.REASONRUDE]: [OzoneReportDefs.REASONHARASSMENTOTHER],
|
[RootReportDefs.reasonSexual.value]:
|
||||||
[RootReportDefs.REASONOTHER]: [OzoneReportDefs.REASONOTHER],
|
OzoneReportDefs.reasonSexualUnlabeled.value,
|
||||||
[RootReportDefs.REASONAPPEAL]: [OzoneReportDefs.REASONAPPEAL],
|
[RootReportDefs.reasonRude.value]:
|
||||||
|
OzoneReportDefs.reasonHarassmentOther.value,
|
||||||
|
[RootReportDefs.reasonOther.value]: OzoneReportDefs.reasonOther.value,
|
||||||
|
[RootReportDefs.reasonAppeal.value]: OzoneReportDefs.reasonAppeal.value,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set of report reasons that should optionally include additional details from
|
* Set of report reasons that should optionally include additional details from
|
||||||
* the reporter.
|
* the reporter.
|
||||||
*/
|
*/
|
||||||
export const OTHER_REPORT_REASONS: Set<OzoneReportDefs.ReasonType> = new Set([
|
export const OTHER_REPORT_REASONS: Set<OzoneReasonType> = new Set([
|
||||||
OzoneReportDefs.REASONVIOLENCEOTHER,
|
OzoneReportDefs.reasonViolenceOther.value,
|
||||||
OzoneReportDefs.REASONSEXUALOTHER,
|
OzoneReportDefs.reasonSexualOther.value,
|
||||||
OzoneReportDefs.REASONCHILDSAFETYOTHER,
|
OzoneReportDefs.reasonChildSafetyOther.value,
|
||||||
OzoneReportDefs.REASONHARASSMENTOTHER,
|
OzoneReportDefs.reasonHarassmentOther.value,
|
||||||
OzoneReportDefs.REASONMISLEADINGOTHER,
|
OzoneReportDefs.reasonMisleadingOther.value,
|
||||||
OzoneReportDefs.REASONRULEOTHER,
|
OzoneReportDefs.reasonRuleOther.value,
|
||||||
OzoneReportDefs.REASONSELFHARMOTHER,
|
OzoneReportDefs.reasonSelfHarmOther.value,
|
||||||
OzoneReportDefs.REASONOTHER,
|
OzoneReportDefs.reasonOther.value,
|
||||||
])
|
])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set of report reasons that should only be sent to Bluesky's moderation service.
|
* 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<OzoneReasonType> = new Set([
|
||||||
new Set([
|
OzoneReportDefs.reasonChildSafetyCSAM.value,
|
||||||
OzoneReportDefs.REASONCHILDSAFETYCSAM,
|
OzoneReportDefs.reasonChildSafetyGroom.value,
|
||||||
OzoneReportDefs.REASONCHILDSAFETYGROOM,
|
OzoneReportDefs.reasonChildSafetyOther.value,
|
||||||
OzoneReportDefs.REASONCHILDSAFETYOTHER,
|
OzoneReportDefs.reasonViolenceExtremistContent.value,
|
||||||
OzoneReportDefs.REASONVIOLENCEEXTREMISTCONTENT,
|
|
||||||
])
|
])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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 {api} from '@bsky.app/sdk'
|
||||||
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'
|
||||||
@@ -36,6 +36,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,
|
||||||
@@ -184,7 +185,7 @@ function Inner(props: ReportDialogProps) {
|
|||||||
.filter(l => {
|
.filter(l => {
|
||||||
if (!state.selectedOption) return false
|
if (!state.selectedOption) return false
|
||||||
if (isBskyOnlyReason || isBskyOnlySubject) {
|
if (isBskyOnlyReason || isBskyOnlySubject) {
|
||||||
return l.creator.did === BSKY_LABELER_DID
|
return l.creator.did === api.moderation.did
|
||||||
}
|
}
|
||||||
const supportedReasonTypes: string[] | undefined = l.reasonTypes
|
const supportedReasonTypes: string[] | undefined = l.reasonTypes
|
||||||
if (supportedReasonTypes === undefined) return true
|
if (supportedReasonTypes === undefined) return true
|
||||||
@@ -932,8 +933,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,13 +1,11 @@
|
|||||||
import {
|
|
||||||
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, tools} from '#/lexicons'
|
||||||
|
|
||||||
|
const OzoneReportDefs = tools.ozone.report.defs
|
||||||
|
|
||||||
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
|
||||||
@@ -66,7 +64,7 @@ export type ReportAction =
|
|||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'selectLabeler'
|
type: 'selectLabeler'
|
||||||
labeler: AppBskyLabelerDefs.LabelerViewDetailed
|
labeler: app.bsky.labeler.defs.LabelerViewDetailed
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'clearLabeler'
|
type: 'clearLabeler'
|
||||||
@@ -116,7 +114,8 @@ export function reducer(state: ReportState, action: ReportAction): ReportState {
|
|||||||
ncii: undefined,
|
ncii: undefined,
|
||||||
}
|
}
|
||||||
case 'selectOption': {
|
case 'selectOption': {
|
||||||
const isNcii = action.option.reason === OzoneReportDefs.REASONSEXUALNCII
|
const isNcii =
|
||||||
|
action.option.reason === OzoneReportDefs.reasonSexualNCII.value
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
selectedOption: action.option,
|
selectedOption: action.option,
|
||||||
|
|||||||
@@ -1,46 +1,56 @@
|
|||||||
import {
|
|
||||||
AppBskyActorDefs,
|
|
||||||
AppBskyFeedDefs,
|
|
||||||
AppBskyFeedPost,
|
|
||||||
AppBskyGraphDefs,
|
|
||||||
} from '@atproto/api'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type ParsedReportSubject,
|
type ParsedReportSubject,
|
||||||
type ReportSubject,
|
type ReportSubject,
|
||||||
} from '#/components/moderation/ReportDialog/types'
|
} from '#/components/moderation/ReportDialog/types'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
export function parseReportSubject(
|
export function parseReportSubject(
|
||||||
subject: ReportSubject,
|
rawSubject: ReportSubject,
|
||||||
): ParsedReportSubject | undefined {
|
): ParsedReportSubject | undefined {
|
||||||
if (!subject) return
|
if (!rawSubject) return
|
||||||
|
|
||||||
if ('convoId' in subject) {
|
if ('convoId' in rawSubject) {
|
||||||
if ('message' in subject) {
|
if ('message' in rawSubject) {
|
||||||
return {
|
return {
|
||||||
type: 'convoMessage',
|
type: 'convoMessage',
|
||||||
...subject,
|
...rawSubject,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
type: 'convo',
|
type: 'convo',
|
||||||
convoId: subject.convoId,
|
convoId: rawSubject.convoId,
|
||||||
did: subject.did,
|
did: rawSubject.did,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO(phase4): drop toLex once ReportSubject is a #/lexicons union. The view
|
||||||
|
* subjects are structurally the #/lexicons shapes; we bridge here so the
|
||||||
|
* `isType` schema guards below narrow against the lexicon `$type`s.
|
||||||
|
*/
|
||||||
|
const subject = bsky.toLex<
|
||||||
|
| app.bsky.actor.defs.ProfileViewBasic
|
||||||
|
| app.bsky.actor.defs.ProfileView
|
||||||
|
| app.bsky.actor.defs.ProfileViewDetailed
|
||||||
|
| app.bsky.actor.defs.StatusView
|
||||||
|
| app.bsky.graph.defs.ListView
|
||||||
|
| app.bsky.feed.defs.GeneratorView
|
||||||
|
| app.bsky.graph.defs.StarterPackView
|
||||||
|
| app.bsky.feed.defs.PostView
|
||||||
|
>(rawSubject)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
AppBskyActorDefs.isProfileViewBasic(subject) ||
|
bsky.isType(app.bsky.actor.defs.profileViewBasic, subject) ||
|
||||||
AppBskyActorDefs.isProfileView(subject) ||
|
bsky.isType(app.bsky.actor.defs.profileView, subject) ||
|
||||||
AppBskyActorDefs.isProfileViewDetailed(subject)
|
bsky.isType(app.bsky.actor.defs.profileViewDetailed, subject)
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
type: 'account',
|
type: 'account',
|
||||||
did: subject.did,
|
did: subject.did,
|
||||||
nsid: 'app.bsky.actor.profile',
|
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
|
if (!subject.uri || !subject.cid) return
|
||||||
return {
|
return {
|
||||||
type: 'status',
|
type: 'status',
|
||||||
@@ -48,36 +58,31 @@ export function parseReportSubject(
|
|||||||
cid: subject.cid,
|
cid: subject.cid,
|
||||||
nsid: 'app.bsky.actor.status',
|
nsid: 'app.bsky.actor.status',
|
||||||
}
|
}
|
||||||
} else if (AppBskyGraphDefs.isListView(subject)) {
|
} else if (bsky.isType(app.bsky.graph.defs.listView, subject)) {
|
||||||
return {
|
return {
|
||||||
type: 'list',
|
type: 'list',
|
||||||
uri: subject.uri,
|
uri: subject.uri,
|
||||||
cid: subject.cid,
|
cid: subject.cid,
|
||||||
nsid: 'app.bsky.graph.list',
|
nsid: 'app.bsky.graph.list',
|
||||||
}
|
}
|
||||||
} else if (AppBskyFeedDefs.isGeneratorView(subject)) {
|
} else if (bsky.isType(app.bsky.feed.defs.generatorView, subject)) {
|
||||||
return {
|
return {
|
||||||
type: 'feed',
|
type: 'feed',
|
||||||
uri: subject.uri,
|
uri: subject.uri,
|
||||||
cid: subject.cid,
|
cid: subject.cid,
|
||||||
nsid: 'app.bsky.feed.generator',
|
nsid: 'app.bsky.feed.generator',
|
||||||
}
|
}
|
||||||
} else if (AppBskyGraphDefs.isStarterPackView(subject)) {
|
} else if (bsky.isType(app.bsky.graph.defs.starterPackView, subject)) {
|
||||||
return {
|
return {
|
||||||
type: 'starterPack',
|
type: 'starterPack',
|
||||||
uri: subject.uri,
|
uri: subject.uri,
|
||||||
cid: subject.cid,
|
cid: subject.cid,
|
||||||
nsid: 'app.bsky.graph.starterPack',
|
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 record = subject.record
|
||||||
const embed = bsky.post.parseEmbed(subject.embed)
|
const embed = bsky.post.parseEmbed(subject.embed)
|
||||||
if (
|
if (bsky.isType(app.bsky.feed.post, record)) {
|
||||||
bsky.dangerousIsType<AppBskyFeedPost.Record>(
|
|
||||||
record,
|
|
||||||
AppBskyFeedPost.isRecord,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return {
|
return {
|
||||||
type: 'post',
|
type: 'post',
|
||||||
uri: subject.uri,
|
uri: subject.uri,
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import {useMemo} from 'react'
|
import {useMemo} from 'react'
|
||||||
import {ToolsOzoneReportDefs as OzoneReportDefs} 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 {tools} from '#/lexicons'
|
||||||
|
|
||||||
|
const OzoneReportDefs = tools.ozone.report.defs
|
||||||
|
|
||||||
export type ReportCategory =
|
export type ReportCategory =
|
||||||
| 'childSafety'
|
| 'childSafety'
|
||||||
| 'violencePhysicalHarm'
|
| 'violencePhysicalHarm'
|
||||||
@@ -22,7 +25,7 @@ export type ReportCategoryConfig = {
|
|||||||
|
|
||||||
export type ReportOption = {
|
export type ReportOption = {
|
||||||
title: string
|
title: string
|
||||||
reason: OzoneReportDefs.ReasonType
|
reason: tools.ozone.report.defs.ReasonType
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useReportOptions() {
|
export function useReportOptions() {
|
||||||
@@ -37,27 +40,27 @@ export function useReportOptions() {
|
|||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
title: _(msg`Spam`),
|
title: _(msg`Spam`),
|
||||||
reason: OzoneReportDefs.REASONMISLEADINGSPAM,
|
reason: OzoneReportDefs.reasonMisleadingSpam.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Scam`),
|
title: _(msg`Scam`),
|
||||||
reason: OzoneReportDefs.REASONMISLEADINGSCAM,
|
reason: OzoneReportDefs.reasonMisleadingScam.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Fake account or bot`),
|
title: _(msg`Fake account or bot`),
|
||||||
reason: OzoneReportDefs.REASONMISLEADINGBOT,
|
reason: OzoneReportDefs.reasonMisleadingBot.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Impersonation`),
|
title: _(msg`Impersonation`),
|
||||||
reason: OzoneReportDefs.REASONMISLEADINGIMPERSONATION,
|
reason: OzoneReportDefs.reasonMisleadingImpersonation.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`False information about elections`),
|
title: _(msg`False information about elections`),
|
||||||
reason: OzoneReportDefs.REASONMISLEADINGELECTIONS,
|
reason: OzoneReportDefs.reasonMisleadingElections.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Other misleading content`),
|
title: _(msg`Other misleading content`),
|
||||||
reason: OzoneReportDefs.REASONMISLEADINGOTHER,
|
reason: OzoneReportDefs.reasonMisleadingOther.value,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -70,27 +73,27 @@ export function useReportOptions() {
|
|||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
title: _(msg`Unlabeled adult content`),
|
title: _(msg`Unlabeled adult content`),
|
||||||
reason: OzoneReportDefs.REASONSEXUALUNLABELED,
|
reason: OzoneReportDefs.reasonSexualUnlabeled.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Adult sexual abuse content`),
|
title: _(msg`Adult sexual abuse content`),
|
||||||
reason: OzoneReportDefs.REASONSEXUALABUSECONTENT,
|
reason: OzoneReportDefs.reasonSexualAbuseContent.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Non-consensual intimate imagery`),
|
title: _(msg`Non-consensual intimate imagery`),
|
||||||
reason: OzoneReportDefs.REASONSEXUALNCII,
|
reason: OzoneReportDefs.reasonSexualNCII.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Deepfake adult content`),
|
title: _(msg`Deepfake adult content`),
|
||||||
reason: OzoneReportDefs.REASONSEXUALDEEPFAKE,
|
reason: OzoneReportDefs.reasonSexualDeepfake.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Animal sexual abuse`),
|
title: _(msg`Animal sexual abuse`),
|
||||||
reason: OzoneReportDefs.REASONSEXUALANIMAL,
|
reason: OzoneReportDefs.reasonSexualAnimal.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Other sexual violence content`),
|
title: _(msg`Other sexual violence content`),
|
||||||
reason: OzoneReportDefs.REASONSEXUALOTHER,
|
reason: OzoneReportDefs.reasonSexualOther.value,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -101,23 +104,23 @@ export function useReportOptions() {
|
|||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
title: _(msg`Trolling`),
|
title: _(msg`Trolling`),
|
||||||
reason: OzoneReportDefs.REASONHARASSMENTTROLL,
|
reason: OzoneReportDefs.reasonHarassmentTroll.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Targeted harassment`),
|
title: _(msg`Targeted harassment`),
|
||||||
reason: OzoneReportDefs.REASONHARASSMENTTARGETED,
|
reason: OzoneReportDefs.reasonHarassmentTargeted.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Hate speech`),
|
title: _(msg`Hate speech`),
|
||||||
reason: OzoneReportDefs.REASONHARASSMENTHATESPEECH,
|
reason: OzoneReportDefs.reasonHarassmentHateSpeech.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Doxxing`),
|
title: _(msg`Doxxing`),
|
||||||
reason: OzoneReportDefs.REASONHARASSMENTDOXXING,
|
reason: OzoneReportDefs.reasonHarassmentDoxxing.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Other harassing or hateful content`),
|
title: _(msg`Other harassing or hateful content`),
|
||||||
reason: OzoneReportDefs.REASONHARASSMENTOTHER,
|
reason: OzoneReportDefs.reasonHarassmentOther.value,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -128,31 +131,31 @@ export function useReportOptions() {
|
|||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
title: _(msg`Animal welfare`),
|
title: _(msg`Animal welfare`),
|
||||||
reason: OzoneReportDefs.REASONVIOLENCEANIMAL,
|
reason: OzoneReportDefs.reasonViolenceAnimal.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Threats or incitement`),
|
title: _(msg`Threats or incitement`),
|
||||||
reason: OzoneReportDefs.REASONVIOLENCETHREATS,
|
reason: OzoneReportDefs.reasonViolenceThreats.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Graphic violent content`),
|
title: _(msg`Graphic violent content`),
|
||||||
reason: OzoneReportDefs.REASONVIOLENCEGRAPHICCONTENT,
|
reason: OzoneReportDefs.reasonViolenceGraphicContent.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Glorification of violence`),
|
title: _(msg`Glorification of violence`),
|
||||||
reason: OzoneReportDefs.REASONVIOLENCEGLORIFICATION,
|
reason: OzoneReportDefs.reasonViolenceGlorification.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Extremist content`),
|
title: _(msg`Extremist content`),
|
||||||
reason: OzoneReportDefs.REASONVIOLENCEEXTREMISTCONTENT,
|
reason: OzoneReportDefs.reasonViolenceExtremistContent.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Human trafficking`),
|
title: _(msg`Human trafficking`),
|
||||||
reason: OzoneReportDefs.REASONVIOLENCETRAFFICKING,
|
reason: OzoneReportDefs.reasonViolenceTrafficking.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Other violent content`),
|
title: _(msg`Other violent content`),
|
||||||
reason: OzoneReportDefs.REASONVIOLENCEOTHER,
|
reason: OzoneReportDefs.reasonViolenceOther.value,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -163,23 +166,23 @@ export function useReportOptions() {
|
|||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
title: _(msg`Child Sexual Abuse Material (CSAM)`),
|
title: _(msg`Child Sexual Abuse Material (CSAM)`),
|
||||||
reason: OzoneReportDefs.REASONCHILDSAFETYCSAM,
|
reason: OzoneReportDefs.reasonChildSafetyCSAM.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Grooming or predatory behavior`),
|
title: _(msg`Grooming or predatory behavior`),
|
||||||
reason: OzoneReportDefs.REASONCHILDSAFETYGROOM,
|
reason: OzoneReportDefs.reasonChildSafetyGroom.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Privacy violation of a minor`),
|
title: _(msg`Privacy violation of a minor`),
|
||||||
reason: OzoneReportDefs.REASONCHILDSAFETYPRIVACY,
|
reason: OzoneReportDefs.reasonChildSafetyPrivacy.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Minor harassment or bullying`),
|
title: _(msg`Minor harassment or bullying`),
|
||||||
reason: OzoneReportDefs.REASONCHILDSAFETYHARASSMENT,
|
reason: OzoneReportDefs.reasonChildSafetyHarassment.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Other child safety issue`),
|
title: _(msg`Other child safety issue`),
|
||||||
reason: OzoneReportDefs.REASONCHILDSAFETYOTHER,
|
reason: OzoneReportDefs.reasonChildSafetyOther.value,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -190,23 +193,23 @@ export function useReportOptions() {
|
|||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
title: _(msg`Content promoting or depicting self-harm`),
|
title: _(msg`Content promoting or depicting self-harm`),
|
||||||
reason: OzoneReportDefs.REASONSELFHARMCONTENT,
|
reason: OzoneReportDefs.reasonSelfHarmContent.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Eating disorders`),
|
title: _(msg`Eating disorders`),
|
||||||
reason: OzoneReportDefs.REASONSELFHARMED,
|
reason: OzoneReportDefs.reasonSelfHarmED.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Dangerous challenges or activities`),
|
title: _(msg`Dangerous challenges or activities`),
|
||||||
reason: OzoneReportDefs.REASONSELFHARMSTUNTS,
|
reason: OzoneReportDefs.reasonSelfHarmStunts.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Dangerous substances or drug abuse`),
|
title: _(msg`Dangerous substances or drug abuse`),
|
||||||
reason: OzoneReportDefs.REASONSELFHARMSUBSTANCES,
|
reason: OzoneReportDefs.reasonSelfHarmSubstances.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Other dangerous content`),
|
title: _(msg`Other dangerous content`),
|
||||||
reason: OzoneReportDefs.REASONSELFHARMOTHER,
|
reason: OzoneReportDefs.reasonSelfHarmOther.value,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -217,19 +220,19 @@ export function useReportOptions() {
|
|||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
title: _(msg`Hacking or system attacks`),
|
title: _(msg`Hacking or system attacks`),
|
||||||
reason: OzoneReportDefs.REASONRULESITESECURITY,
|
reason: OzoneReportDefs.reasonRuleSiteSecurity.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Promoting or selling prohibited items or services`),
|
title: _(msg`Promoting or selling prohibited items or services`),
|
||||||
reason: OzoneReportDefs.REASONRULEPROHIBITEDSALES,
|
reason: OzoneReportDefs.reasonRuleProhibitedSales.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Banned user returning`),
|
title: _(msg`Banned user returning`),
|
||||||
reason: OzoneReportDefs.REASONRULEBANEVASION,
|
reason: OzoneReportDefs.reasonRuleBanEvasion.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: _(msg`Other network rule-breaking`),
|
title: _(msg`Other network rule-breaking`),
|
||||||
reason: OzoneReportDefs.REASONRULEOTHER,
|
reason: OzoneReportDefs.reasonRuleOther.value,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -240,7 +243,7 @@ export function useReportOptions() {
|
|||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
title: _(msg`Other`),
|
title: _(msg`Other`),
|
||||||
reason: OzoneReportDefs.REASONOTHER,
|
reason: OzoneReportDefs.reasonOther.value,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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,5 +1,5 @@
|
|||||||
import {createContext, useContext, useMemo} from 'react'
|
import {createContext, useContext, useMemo} from 'react'
|
||||||
import {hasMutedWord} from '@atproto/api'
|
import {hasMutedWord} from '@bsky.app/sdk/moderation'
|
||||||
import {QueryClient, useQuery} from '@tanstack/react-query'
|
import {QueryClient, useQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {useOnAppStateChange} from '#/lib/appState'
|
import {useOnAppStateChange} from '#/lib/appState'
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import {useEffect} from 'react'
|
import {useEffect} from 'react'
|
||||||
import {type Agent, AppBskyActorDefs, asPredicate} from '@atproto/api'
|
import {getPreferences, updateLiveEventPreferences} from '@bsky.app/sdk'
|
||||||
import {useMutation, useQueryClient} from '@tanstack/react-query'
|
import {useMutation, useQueryClient} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
preferencesQueryKey,
|
preferencesQueryKey,
|
||||||
usePreferencesQuery,
|
usePreferencesQuery,
|
||||||
} from '#/state/queries/preferences'
|
} from '#/state/queries/preferences'
|
||||||
import {useAgent} from '#/state/session'
|
import {usePdsClient} from '#/state/session'
|
||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
import * as env from '#/env'
|
import * as env from '#/env'
|
||||||
import {IS_WEB} from '#/env'
|
import {IS_WEB} from '#/env'
|
||||||
@@ -14,10 +14,11 @@ import {
|
|||||||
type LiveEventFeed,
|
type LiveEventFeed,
|
||||||
type LiveEventFeedMetricContext,
|
type LiveEventFeedMetricContext,
|
||||||
} from '#/features/liveEvents/types'
|
} from '#/features/liveEvents/types'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
|
|
||||||
export type LiveEventPreferencesAction = Parameters<
|
export type LiveEventPreferencesAction = Parameters<
|
||||||
Agent['updateLiveEventPreferences']
|
typeof updateLiveEventPreferences
|
||||||
>[0] & {
|
>[1] & {
|
||||||
/**
|
/**
|
||||||
* Flag that is internal to this hook, do not set when updating prefs
|
* Flag that is internal to this hook, do not set when updating prefs
|
||||||
*/
|
*/
|
||||||
@@ -38,7 +39,7 @@ export function useLiveEventPreferences() {
|
|||||||
|
|
||||||
function useWebOnlyDebugLiveEventPreferences() {
|
function useWebOnlyDebugLiveEventPreferences() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const agent = useAgent()
|
const pdsClient = usePdsClient()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (env.IS_DEV && IS_WEB && typeof window !== 'undefined') {
|
if (env.IS_DEV && IS_WEB && typeof window !== 'undefined') {
|
||||||
@@ -46,14 +47,14 @@ function useWebOnlyDebugLiveEventPreferences() {
|
|||||||
window.__updateLiveEventPreferences = async (
|
window.__updateLiveEventPreferences = async (
|
||||||
action: LiveEventPreferencesAction,
|
action: LiveEventPreferencesAction,
|
||||||
) => {
|
) => {
|
||||||
await agent.updateLiveEventPreferences(action)
|
await pdsClient.call(updateLiveEventPreferences, action)
|
||||||
// triggers a refetch
|
// triggers a refetch
|
||||||
await queryClient.invalidateQueries({
|
await queryClient.invalidateQueries({
|
||||||
queryKey: preferencesQueryKey,
|
queryKey: preferencesQueryKey,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [agent, queryClient])
|
}, [pdsClient, queryClient])
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useUpdateLiveEventPreferences(props: {
|
export function useUpdateLiveEventPreferences(props: {
|
||||||
@@ -65,10 +66,10 @@ export function useUpdateLiveEventPreferences(props: {
|
|||||||
}) {
|
}) {
|
||||||
const ax = useAnalytics()
|
const ax = useAnalytics()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const agent = useAgent()
|
const pdsClient = usePdsClient()
|
||||||
|
|
||||||
return useMutation<
|
return useMutation<
|
||||||
AppBskyActorDefs.LiveEventPreferences,
|
app.bsky.actor.defs.LiveEventPreferences,
|
||||||
Error,
|
Error,
|
||||||
LiveEventPreferencesAction,
|
LiveEventPreferencesAction,
|
||||||
{undoAction: LiveEventPreferencesAction | null}
|
{undoAction: LiveEventPreferencesAction | null}
|
||||||
@@ -108,10 +109,14 @@ export function useUpdateLiveEventPreferences(props: {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mutationFn: async action => {
|
mutationFn: async action => {
|
||||||
const updated = await agent.updateLiveEventPreferences(action)
|
/*
|
||||||
const prefs = updated.find(p =>
|
* The SDK action returns void, so after applying the update we read the
|
||||||
asPredicate(AppBskyActorDefs.validateLiveEventPreferences)(p),
|
* fresh, interpreted preferences back to obtain the updated
|
||||||
)
|
* `liveEventPreferences` (the SDK extracts it from the raw prefs array for
|
||||||
|
* us, replacing the old `asPredicate(...).find(...)` lookup).
|
||||||
|
*/
|
||||||
|
await pdsClient.call(updateLiveEventPreferences, action)
|
||||||
|
const {liveEventPreferences: prefs} = await pdsClient.call(getPreferences)
|
||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'hideFeed':
|
case 'hideFeed':
|
||||||
@@ -138,7 +143,7 @@ export function useUpdateLiveEventPreferences(props: {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'toggleHideAllFeeds': {
|
case 'toggleHideAllFeeds': {
|
||||||
if (prefs!.hideAllFeeds) {
|
if (prefs.hideAllFeeds) {
|
||||||
ax.metric('liveEvents:hideAllFeedBanners', {
|
ax.metric('liveEvents:hideAllFeedBanners', {
|
||||||
context: props.metricContext,
|
context: props.metricContext,
|
||||||
})
|
})
|
||||||
@@ -156,7 +161,7 @@ export function useUpdateLiveEventPreferences(props: {
|
|||||||
queryKey: preferencesQueryKey,
|
queryKey: preferencesQueryKey,
|
||||||
})
|
})
|
||||||
|
|
||||||
return prefs!
|
return prefs
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import {useMemo, useState} from 'react'
|
import {useMemo, useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {type AppBskyActorDefs, type AppBskyEmbedExternal} 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'
|
||||||
@@ -26,6 +25,7 @@ import {
|
|||||||
useUpsertLiveStatusMutation,
|
useUpsertLiveStatusMutation,
|
||||||
} from '#/features/liveNow'
|
} from '#/features/liveNow'
|
||||||
import {LinkPreview} from '#/features/liveNow/components/LinkPreview'
|
import {LinkPreview} from '#/features/liveNow/components/LinkPreview'
|
||||||
|
import {type app} from '#/lexicons'
|
||||||
|
|
||||||
export function EditLiveDialog({
|
export function EditLiveDialog({
|
||||||
control,
|
control,
|
||||||
@@ -33,8 +33,8 @@ export function EditLiveDialog({
|
|||||||
embed,
|
embed,
|
||||||
}: {
|
}: {
|
||||||
control: Dialog.DialogControlProps
|
control: Dialog.DialogControlProps
|
||||||
status: AppBskyActorDefs.StatusView
|
status: app.bsky.actor.defs.StatusView
|
||||||
embed: AppBskyEmbedExternal.View
|
embed: app.bsky.embed.external.View
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Dialog.Outer control={control} nativeOptions={{preventExpansion: true}}>
|
<Dialog.Outer control={control} nativeOptions={{preventExpansion: true}}>
|
||||||
@@ -48,14 +48,14 @@ function DialogInner({
|
|||||||
status,
|
status,
|
||||||
embed,
|
embed,
|
||||||
}: {
|
}: {
|
||||||
status: AppBskyActorDefs.StatusView
|
status: app.bsky.actor.defs.StatusView
|
||||||
embed: AppBskyEmbedExternal.View
|
embed: app.bsky.embed.external.View
|
||||||
}) {
|
}) {
|
||||||
const control = Dialog.useDialogContext()
|
const control = Dialog.useDialogContext()
|
||||||
const {_, i18n} = useLingui()
|
const {_, i18n} = useLingui()
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
|
||||||
const [liveLink, setLiveLink] = useState(embed.external.uri)
|
const [liveLink, setLiveLink] = useState<string>(embed.external.uri)
|
||||||
const [liveLinkError, setLiveLinkError] = useState('')
|
const [liveLinkError, setLiveLinkError] = useState('')
|
||||||
const tick = useTickEveryMinute()
|
const tick = useTickEveryMinute()
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
import {useCallback, useState} from 'react'
|
import {useCallback, useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {type AppBskyActorDefs, ToolsOzoneReportDefs} from '@atproto/api'
|
import {type AppBskyActorDefs} from '@atproto/api'
|
||||||
|
import {api} from '@bsky.app/sdk'
|
||||||
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'
|
||||||
import {useMutation} from '@tanstack/react-query'
|
import {useMutation} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {BLUESKY_MOD_SERVICE_HEADERS} from '#/lib/constants'
|
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {useAgent} from '#/state/session'
|
import {useMaybePdsClient, useSession} from '#/state/session'
|
||||||
import {atoms as a, web} from '#/alf'
|
import {atoms as a, web} from '#/alf'
|
||||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
import {Loader} from '#/components/Loader'
|
import {Loader} from '#/components/Loader'
|
||||||
import * as Toast from '#/components/Toast'
|
import * as Toast from '#/components/Toast'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
import {com, tools} from '#/lexicons'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
|
|
||||||
export function GoLiveDisabledDialog({
|
export function GoLiveDisabledDialog({
|
||||||
control,
|
control,
|
||||||
@@ -39,12 +41,13 @@ export function DialogInner({
|
|||||||
status: AppBskyActorDefs.StatusView
|
status: AppBskyActorDefs.StatusView
|
||||||
}) {
|
}) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const agent = useAgent()
|
const {currentAccount} = useSession()
|
||||||
|
const pdsClient = useMaybePdsClient()
|
||||||
const [details, setDetails] = useState('')
|
const [details, setDetails] = useState('')
|
||||||
|
|
||||||
const {mutate, isPending} = useMutation({
|
const {mutate, isPending} = useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
if (!agent.session?.did) {
|
if (!currentAccount?.did || !pdsClient) {
|
||||||
throw new Error('Not logged in')
|
throw new Error('Not logged in')
|
||||||
}
|
}
|
||||||
if (!status.uri || !status.cid) {
|
if (!status.uri || !status.cid) {
|
||||||
@@ -56,19 +59,19 @@ export function DialogInner({
|
|||||||
details,
|
details,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
await agent.createModerationReport(
|
await pdsClient.call(
|
||||||
{
|
com.atproto.moderation.createReport,
|
||||||
reasonType: ToolsOzoneReportDefs.REASONAPPEAL,
|
toLex<com.atproto.moderation.createReport.$InputBody>({
|
||||||
|
reasonType: tools.ozone.report.defs.reasonAppeal.value,
|
||||||
subject: {
|
subject: {
|
||||||
$type: 'com.atproto.repo.strongRef',
|
$type: 'com.atproto.repo.strongRef',
|
||||||
uri: status.uri,
|
uri: status.uri,
|
||||||
cid: status.cid,
|
cid: status.cid,
|
||||||
},
|
},
|
||||||
reason: details,
|
reason: details,
|
||||||
},
|
}),
|
||||||
{
|
{
|
||||||
encoding: 'application/json',
|
service: api.moderation.service,
|
||||||
headers: BLUESKY_MOD_SERVICE_HEADERS,
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import {useCallback, useMemo} from 'react'
|
import {useCallback, useMemo} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {Image} from 'expo-image'
|
import {Image} from 'expo-image'
|
||||||
import {
|
import {moderateStatus} from '@bsky.app/sdk/moderation'
|
||||||
type AppBskyActorDefs,
|
|
||||||
type AppBskyEmbedExternal,
|
|
||||||
moderateStatus,
|
|
||||||
} from '@atproto/api'
|
|
||||||
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'
|
||||||
import {useQueryClient} from '@tanstack/react-query'
|
import {useQueryClient} from '@tanstack/react-query'
|
||||||
@@ -30,7 +26,8 @@ import * as ProfileCard from '#/components/ProfileCard'
|
|||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
import {LiveIndicator} from '#/features/liveNow/components/LiveIndicator'
|
import {LiveIndicator} from '#/features/liveNow/components/LiveIndicator'
|
||||||
import type * as bsky from '#/types/bsky'
|
import {type app} from '#/lexicons'
|
||||||
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
export function LiveStatusDialog({
|
export function LiveStatusDialog({
|
||||||
control,
|
control,
|
||||||
@@ -40,8 +37,8 @@ export function LiveStatusDialog({
|
|||||||
}: {
|
}: {
|
||||||
control: Dialog.DialogControlProps
|
control: Dialog.DialogControlProps
|
||||||
profile: bsky.profile.AnyProfileView
|
profile: bsky.profile.AnyProfileView
|
||||||
status: AppBskyActorDefs.StatusView
|
status: app.bsky.actor.defs.StatusView
|
||||||
embed: AppBskyEmbedExternal.View
|
embed: app.bsky.embed.external.View
|
||||||
}) {
|
}) {
|
||||||
const navigation = useNavigation<NavigationProp>()
|
const navigation = useNavigation<NavigationProp>()
|
||||||
return (
|
return (
|
||||||
@@ -64,9 +61,9 @@ function DialogInner({
|
|||||||
status,
|
status,
|
||||||
}: {
|
}: {
|
||||||
profile: bsky.profile.AnyProfileView
|
profile: bsky.profile.AnyProfileView
|
||||||
embed: AppBskyEmbedExternal.View
|
embed: app.bsky.embed.external.View
|
||||||
navigation: NavigationProp
|
navigation: NavigationProp
|
||||||
status: AppBskyActorDefs.StatusView
|
status: app.bsky.actor.defs.StatusView
|
||||||
}) {
|
}) {
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const control = Dialog.useDialogContext()
|
const control = Dialog.useDialogContext()
|
||||||
@@ -102,9 +99,9 @@ export function LiveStatus({
|
|||||||
padding = 'xl',
|
padding = 'xl',
|
||||||
onPressOpenProfile,
|
onPressOpenProfile,
|
||||||
}: {
|
}: {
|
||||||
status: AppBskyActorDefs.StatusView
|
status: app.bsky.actor.defs.StatusView
|
||||||
profile: bsky.profile.AnyProfileView
|
profile: bsky.profile.AnyProfileView
|
||||||
embed: AppBskyEmbedExternal.View
|
embed: app.bsky.embed.external.View
|
||||||
padding?: 'lg' | 'xl'
|
padding?: 'lg' | 'xl'
|
||||||
onPressOpenProfile: () => void
|
onPressOpenProfile: () => void
|
||||||
}) {
|
}) {
|
||||||
@@ -118,7 +115,8 @@ export function LiveStatus({
|
|||||||
const dialogContext = Dialog.useDialogContext()
|
const dialogContext = Dialog.useDialogContext()
|
||||||
const moderation = useMemo(() => {
|
const moderation = useMemo(() => {
|
||||||
if (!moderationOpts) return undefined
|
if (!moderationOpts) return undefined
|
||||||
return moderateStatus(profile, moderationOpts)
|
// TODO(phase4): drop toLex once profile producers emit #/lexicons views
|
||||||
|
return moderateStatus(bsky.toLex(profile), moderationOpts)
|
||||||
}, [profile, moderationOpts])
|
}, [profile, moderationOpts])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import {useMemo} from 'react'
|
import {useMemo} from 'react'
|
||||||
import {
|
|
||||||
type $Typed,
|
|
||||||
type AppBskyActorDefs,
|
|
||||||
type AppBskyActorStatus,
|
|
||||||
AppBskyEmbedExternal,
|
|
||||||
AtUri,
|
|
||||||
ComAtprotoRepoPutRecord,
|
|
||||||
moderateStatus,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {retry} from '@atproto/common-web'
|
import {retry} from '@atproto/common-web'
|
||||||
|
import {type $Typed} from '@atproto/lex'
|
||||||
|
import {
|
||||||
|
type AtIdentifierString,
|
||||||
|
AtUri,
|
||||||
|
type DatetimeString,
|
||||||
|
type UriString,
|
||||||
|
} from '@atproto/syntax'
|
||||||
|
import {moderateStatus} 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 {useMutation, useQuery, useQueryClient} from '@tanstack/react-query'
|
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query'
|
||||||
@@ -17,19 +16,21 @@ import {isAfter, parseISO} from 'date-fns'
|
|||||||
import {uploadBlob} from '#/lib/api'
|
import {uploadBlob} from '#/lib/api'
|
||||||
import {imageToThumb} from '#/lib/api/resolve'
|
import {imageToThumb} from '#/lib/api/resolve'
|
||||||
import {getLinkMeta, type LinkMeta} from '#/lib/link-meta/link-meta'
|
import {getLinkMeta, type LinkMeta} from '#/lib/link-meta/link-meta'
|
||||||
|
import {getErrorName} from '#/lib/xrpc-error'
|
||||||
import {useAppConfig} from '#/state/appConfig'
|
import {useAppConfig} from '#/state/appConfig'
|
||||||
import {
|
import {
|
||||||
updateProfileShadow,
|
updateProfileShadow,
|
||||||
useMaybeProfileShadow,
|
useMaybeProfileShadow,
|
||||||
} from '#/state/cache/profile-shadow'
|
} from '#/state/cache/profile-shadow'
|
||||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||||
import {useAgent, useSession} from '#/state/session'
|
import {useAgent, usePdsClient, useSession} from '#/state/session'
|
||||||
import {useTickEveryMinute} from '#/state/shell'
|
import {useTickEveryMinute} from '#/state/shell'
|
||||||
import {useDialogContext} from '#/components/Dialog'
|
import {useDialogContext} from '#/components/Dialog'
|
||||||
import * as Toast from '#/components/Toast'
|
import * as Toast from '#/components/Toast'
|
||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
import {getLiveNowHost, getLiveServiceNames} from '#/features/liveNow/utils'
|
import {getLiveNowHost, getLiveServiceNames} from '#/features/liveNow/utils'
|
||||||
import type * as bsky from '#/types/bsky'
|
import {app, com} from '#/lexicons'
|
||||||
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
export * from '#/features/liveNow/utils'
|
export * from '#/features/liveNow/utils'
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ const DEFAULT_STATE = {
|
|||||||
isDisabled: false,
|
isDisabled: false,
|
||||||
isActive: false,
|
isActive: false,
|
||||||
record: {},
|
record: {},
|
||||||
} satisfies AppBskyActorDefs.StatusView
|
} satisfies app.bsky.actor.defs.StatusView
|
||||||
|
|
||||||
export type LiveNowConfig = {
|
export type LiveNowConfig = {
|
||||||
canGoLive: boolean
|
canGoLive: boolean
|
||||||
@@ -104,7 +105,8 @@ export function useActorStatus(actor?: bsky.profile.AnyProfileView) {
|
|||||||
const moderation = useMemo(() => {
|
const moderation = useMemo(() => {
|
||||||
if (!actor || !('status' in actor && actor.status)) return undefined
|
if (!actor || !('status' in actor && actor.status)) return undefined
|
||||||
if (!moderationOpts) return undefined
|
if (!moderationOpts) return undefined
|
||||||
return moderateStatus(actor, moderationOpts)
|
// TODO(phase4): drop toLex once profile producers emit #/lexicons views
|
||||||
|
return moderateStatus(bsky.toLex(actor), moderationOpts)
|
||||||
}, [actor, moderationOpts])
|
}, [actor, moderationOpts])
|
||||||
|
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
@@ -118,31 +120,37 @@ export function useActorStatus(actor?: bsky.profile.AnyProfileView) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shadowed && 'status' in shadowed && shadowed.status) {
|
if (shadowed && 'status' in shadowed && shadowed.status) {
|
||||||
const isValid = isStatusValidForViewers(shadowed.status, config)
|
/*
|
||||||
const isDisabled = shadowed.status.isDisabled || false
|
* TODO(phase4): drop toLex once profile-shadow emits #/lexicons views.
|
||||||
const isActive = isStatusStillActive(shadowed.status.expiresAt)
|
* The shadow store still holds old `@atproto/api` StatusViews, so brand
|
||||||
|
* it once here to feed the new-world validation and returned view.
|
||||||
|
*/
|
||||||
|
const status = bsky.toLex<app.bsky.actor.defs.StatusView>(shadowed.status)
|
||||||
|
const isValid = isStatusValidForViewers(status, config)
|
||||||
|
const isDisabled = status.isDisabled || false
|
||||||
|
const isActive = isStatusStillActive(status.expiresAt)
|
||||||
if (isValid && !isDisabled && isActive) {
|
if (isValid && !isDisabled && isActive) {
|
||||||
return {
|
return {
|
||||||
uri: shadowed.status.uri,
|
uri: status.uri,
|
||||||
cid: shadowed.status.cid,
|
cid: status.cid,
|
||||||
isDisabled: false,
|
isDisabled: false,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
status: 'app.bsky.actor.status#live',
|
status: 'app.bsky.actor.status#live',
|
||||||
embed: shadowed.status.embed as $Typed<AppBskyEmbedExternal.View>, // temp_isStatusValid asserts this
|
embed: status.embed as $Typed<app.bsky.embed.external.View>, // temp_isStatusValid asserts this
|
||||||
expiresAt: shadowed.status.expiresAt!, // isStatusStillActive asserts this
|
expiresAt: status.expiresAt!, // isStatusStillActive asserts this
|
||||||
record: shadowed.status.record,
|
record: status.record,
|
||||||
} satisfies AppBskyActorDefs.StatusView
|
} satisfies app.bsky.actor.defs.StatusView
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
uri: shadowed.status.uri,
|
uri: status.uri,
|
||||||
cid: shadowed.status.cid,
|
cid: status.cid,
|
||||||
isDisabled,
|
isDisabled,
|
||||||
isActive: false,
|
isActive: false,
|
||||||
status: 'app.bsky.actor.status#live',
|
status: 'app.bsky.actor.status#live',
|
||||||
embed: shadowed.status.embed as $Typed<AppBskyEmbedExternal.View>, // temp_isStatusValid asserts this
|
embed: status.embed as $Typed<app.bsky.embed.external.View>, // temp_isStatusValid asserts this
|
||||||
expiresAt: shadowed.status.expiresAt!, // isStatusStillActive asserts this
|
expiresAt: status.expiresAt!, // isStatusStillActive asserts this
|
||||||
record: shadowed.status.record,
|
record: status.record,
|
||||||
} satisfies AppBskyActorDefs.StatusView
|
} satisfies app.bsky.actor.defs.StatusView
|
||||||
} else {
|
} else {
|
||||||
return DEFAULT_STATE
|
return DEFAULT_STATE
|
||||||
}
|
}
|
||||||
@@ -162,14 +170,14 @@ export function isStatusStillActive(timeStr: string | undefined) {
|
|||||||
* validate if the status is valid for the acting user e.g. as they go live.
|
* validate if the status is valid for the acting user e.g. as they go live.
|
||||||
*/
|
*/
|
||||||
export function isStatusValidForViewers(
|
export function isStatusValidForViewers(
|
||||||
status: AppBskyActorDefs.StatusView,
|
status: app.bsky.actor.defs.StatusView,
|
||||||
config: LiveNowConfig,
|
config: LiveNowConfig,
|
||||||
) {
|
) {
|
||||||
if (status.status !== 'app.bsky.actor.status#live') return false
|
if (status.status !== 'app.bsky.actor.status#live') return false
|
||||||
if (!status.uri) return false // should not happen, just backwards compat
|
if (!status.uri) return false // should not happen, just backwards compat
|
||||||
try {
|
try {
|
||||||
const {host: liveDid} = new AtUri(status.uri)
|
const {host: liveDid} = new AtUri(status.uri)
|
||||||
if (AppBskyEmbedExternal.isView(status.embed)) {
|
if (bsky.isType(app.bsky.embed.external.view, status.embed)) {
|
||||||
const host = getLiveNowHost(status.embed.external.uri)
|
const host = getLiveNowHost(status.embed.external.uri)
|
||||||
const exception = config.allowedHostsExceptionsByDid.get(liveDid)
|
const exception = config.allowedHostsExceptionsByDid.get(liveDid)
|
||||||
const isValidException = exception ? exception.has(host) : false
|
const isValidException = exception ? exception.has(host) : false
|
||||||
@@ -217,7 +225,7 @@ export function useUpsertLiveStatusMutation(
|
|||||||
) {
|
) {
|
||||||
const ax = useAnalytics()
|
const ax = useAnalytics()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const agent = useAgent()
|
const pdsClient = usePdsClient()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const control = useDialogContext()
|
const control = useDialogContext()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
@@ -226,7 +234,7 @@ export function useUpsertLiveStatusMutation(
|
|||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
if (!currentAccount) throw new Error('Not logged in')
|
if (!currentAccount) throw new Error('Not logged in')
|
||||||
|
|
||||||
let embed: $Typed<AppBskyEmbedExternal.Main> | undefined
|
let embed: $Typed<app.bsky.embed.external.Main> | undefined
|
||||||
|
|
||||||
if (linkMeta) {
|
if (linkMeta) {
|
||||||
let thumb
|
let thumb
|
||||||
@@ -236,11 +244,11 @@ export function useUpsertLiveStatusMutation(
|
|||||||
const img = await imageToThumb(linkMeta.image)
|
const img = await imageToThumb(linkMeta.image)
|
||||||
if (img) {
|
if (img) {
|
||||||
const blob = await uploadBlob(
|
const blob = await uploadBlob(
|
||||||
agent,
|
pdsClient,
|
||||||
img.source.path,
|
img.source.path,
|
||||||
img.source.mime,
|
img.source.mime,
|
||||||
)
|
)
|
||||||
thumb = blob.data.blob
|
thumb = blob.blob
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
ax.logger.error(`Failed to upload thumbnail for live status`, {
|
ax.logger.error(`Failed to upload thumbnail for live status`, {
|
||||||
@@ -257,7 +265,7 @@ export function useUpsertLiveStatusMutation(
|
|||||||
$type: 'app.bsky.embed.external#external',
|
$type: 'app.bsky.embed.external#external',
|
||||||
title: linkMeta.title ?? '',
|
title: linkMeta.title ?? '',
|
||||||
description: linkMeta.description ?? '',
|
description: linkMeta.description ?? '',
|
||||||
uri: linkMeta.url,
|
uri: linkMeta.url as UriString,
|
||||||
thumb,
|
thumb,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -265,32 +273,32 @@ export function useUpsertLiveStatusMutation(
|
|||||||
|
|
||||||
const record = {
|
const record = {
|
||||||
$type: 'app.bsky.actor.status',
|
$type: 'app.bsky.actor.status',
|
||||||
createdAt: createdAt ?? new Date().toISOString(),
|
createdAt: (createdAt ?? new Date().toISOString()) as DatetimeString,
|
||||||
status: 'app.bsky.actor.status#live',
|
status: 'app.bsky.actor.status#live',
|
||||||
durationMinutes: duration,
|
durationMinutes: duration,
|
||||||
embed,
|
embed,
|
||||||
} satisfies AppBskyActorStatus.Record
|
} satisfies app.bsky.actor.status.Main
|
||||||
|
|
||||||
const upsert = async () => {
|
const upsert = async () => {
|
||||||
const repo = currentAccount.did
|
const repo = currentAccount.did as AtIdentifierString
|
||||||
const collection = 'app.bsky.actor.status'
|
const collection = 'app.bsky.actor.status'
|
||||||
|
|
||||||
const existing = await agent.com.atproto.repo
|
const existing = await pdsClient
|
||||||
.getRecord({repo, collection, rkey: 'self'})
|
.call(com.atproto.repo.getRecord, {repo, collection, rkey: 'self'})
|
||||||
.catch(_e => undefined)
|
.catch(_e => undefined)
|
||||||
|
|
||||||
await agent.com.atproto.repo.putRecord({
|
await pdsClient.call(com.atproto.repo.putRecord, {
|
||||||
repo,
|
repo,
|
||||||
collection,
|
collection,
|
||||||
rkey: 'self',
|
rkey: 'self',
|
||||||
record,
|
record,
|
||||||
swapRecord: existing?.data.cid || null,
|
swapRecord: existing?.cid || null,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
await retry(upsert, {
|
await retry(upsert, {
|
||||||
maxRetries: 5,
|
maxRetries: 5,
|
||||||
retryable: e => e instanceof ComAtprotoRepoPutRecord.InvalidSwapError,
|
retryable: e => getErrorName(e) === 'InvalidSwap',
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -347,7 +355,7 @@ export function useUpsertLiveStatusMutation(
|
|||||||
export function useRemoveLiveStatusMutation() {
|
export function useRemoveLiveStatusMutation() {
|
||||||
const ax = useAnalytics()
|
const ax = useAnalytics()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const agent = useAgent()
|
const pdsClient = usePdsClient()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const control = useDialogContext()
|
const control = useDialogContext()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
@@ -356,8 +364,8 @@ export function useRemoveLiveStatusMutation() {
|
|||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
if (!currentAccount) throw new Error('Not logged in')
|
if (!currentAccount) throw new Error('Not logged in')
|
||||||
|
|
||||||
await agent.app.bsky.actor.status.delete({
|
await pdsClient.delete(app.bsky.actor.status, {
|
||||||
repo: currentAccount.did,
|
repo: currentAccount.did as AtIdentifierString,
|
||||||
rkey: 'self',
|
rkey: 'self',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
import {AppBskyActorStatus, AppBskyEmbedExternal} from '@atproto/api'
|
|
||||||
import {type I18n} from '@lingui/core'
|
import {type I18n} from '@lingui/core'
|
||||||
import {plural} from '@lingui/core/macro'
|
import {plural} from '@lingui/core/macro'
|
||||||
import psl from 'psl'
|
import psl from 'psl'
|
||||||
|
|
||||||
|
import {app} from '#/lexicons'
|
||||||
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates a raw status record and returns the typed record, or null if the
|
* Validates a raw status record and returns the typed record, or null if the
|
||||||
* value is not a valid `app.bsky.actor.status` record.
|
* value is not a valid `app.bsky.actor.status` record.
|
||||||
*/
|
*/
|
||||||
export function getValidLiveStatusRecord(
|
export function getValidLiveStatusRecord(
|
||||||
statusRecord: unknown,
|
statusRecord: unknown,
|
||||||
): AppBskyActorStatus.Record | null {
|
): app.bsky.actor.status.Main | null {
|
||||||
if (!AppBskyActorStatus.isRecord(statusRecord)) return null
|
if (!bsky.matches(app.bsky.actor.status, statusRecord)) return null
|
||||||
const validation = AppBskyActorStatus.validateRecord(statusRecord)
|
return statusRecord
|
||||||
if (!validation.success) return null
|
|
||||||
return validation.value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +23,7 @@ export function getValidLiveStatusRecord(
|
|||||||
export function getLiveLinkFromStatusRecord(statusRecord: unknown): string {
|
export function getLiveLinkFromStatusRecord(statusRecord: unknown): string {
|
||||||
const record = getValidLiveStatusRecord(statusRecord)
|
const record = getValidLiveStatusRecord(statusRecord)
|
||||||
if (!record) return ''
|
if (!record) return ''
|
||||||
if (!AppBskyEmbedExternal.isMain(record.embed)) return ''
|
if (!bsky.isType(app.bsky.embed.external, record.embed)) return ''
|
||||||
return record.embed.external.uri
|
return record.embed.external.uri
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
* The jest suite ships global manual mocks for `multiformats/cid` and
|
||||||
|
* `multiformats/hashes/hasher` (in root `__mocks__/`) so unrelated tests don't
|
||||||
|
* pull in real crypto. This test is precisely about the real CID hashing, so we
|
||||||
|
* opt back into the actual implementations here.
|
||||||
|
*/
|
||||||
|
jest.unmock('multiformats/cid')
|
||||||
|
jest.unmock('multiformats/hashes/hasher')
|
||||||
|
|
||||||
|
import {BlobRef} from '@atproto/api'
|
||||||
|
import {CID} from 'multiformats/cid'
|
||||||
|
|
||||||
|
import {computeCid} from '#/lib/api/computeCid'
|
||||||
|
import {type app, type com} from '#/lexicons'
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Golden-CID regression test for the composer post pipeline (design section F).
|
||||||
|
*
|
||||||
|
* `computeCid` hashes a post record in the client so a thread's later posts can
|
||||||
|
* reference earlier posts by CID before the server assigns them. The hash is
|
||||||
|
* byte-sensitive: any drift in how records (especially blobs) are serialized to
|
||||||
|
* DAG-CBOR silently produces the wrong CID and breaks reply chains with NO type
|
||||||
|
* error. These golden values were captured from the PRE-migration `computeCid`
|
||||||
|
* (the `instanceof BlobRef` path) and MUST remain byte-identical after the guard
|
||||||
|
* is changed to the structural `isBlobRef` shape check.
|
||||||
|
*
|
||||||
|
* The blob CID below is a fixed, deterministic CIDv1/raw/sha256 used purely as a
|
||||||
|
* stable fixture - it is not derived from any real upload.
|
||||||
|
*/
|
||||||
|
const BLOB_CID = 'bafkreieq5jui4j25lacwomsqgjeswwl3y5zcdrresptwgmfylxo2depppq'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a post record with an image embed whose blob is the given value. Used to
|
||||||
|
* prove that a `@atproto/api` `BlobRef` class instance (the shape the not-yet
|
||||||
|
* -migrated video path still yields) and a plain-JSON lex blob (the shape lex
|
||||||
|
* `uploadBlob` returns) hash to the SAME CID.
|
||||||
|
*/
|
||||||
|
function postWithImageBlob(blob: unknown): app.bsky.feed.post.Main {
|
||||||
|
return {
|
||||||
|
$type: 'app.bsky.feed.post',
|
||||||
|
createdAt: '2024-01-01T00:00:00.001Z',
|
||||||
|
text: 'post with image',
|
||||||
|
embed: {
|
||||||
|
$type: 'app.bsky.embed.images',
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
image: blob,
|
||||||
|
alt: 'alt text',
|
||||||
|
aspectRatio: {width: 100, height: 200},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
} as app.bsky.feed.post.Main
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('computeCid', () => {
|
||||||
|
it('case 1: plain post record with no blob', async () => {
|
||||||
|
const record: app.bsky.feed.post.Main = {
|
||||||
|
$type: 'app.bsky.feed.post',
|
||||||
|
createdAt: '2024-01-01T00:00:00.000Z',
|
||||||
|
text: 'hello world',
|
||||||
|
}
|
||||||
|
expect(await computeCid(record)).toBe(
|
||||||
|
'bafyreieawtmh7hwfrqpamqkodza5r62bbfhsepe2iyustgxhgbhi6b2lfi',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('case 2: record whose embed carries a BlobRef class instance', async () => {
|
||||||
|
const blob = new BlobRef(CID.parse(BLOB_CID), 'image/jpeg', 12345)
|
||||||
|
expect(await computeCid(postWithImageBlob(blob))).toBe(
|
||||||
|
'bafyreiem7g6vja66nebr7he4fshfnlyndyldbvle2n265oixscmepjcbii',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('case 2b: a plain-JSON blob object hashes identically to the class instance', async () => {
|
||||||
|
/*
|
||||||
|
* This is the post-migration shape: lex `uploadBlob` returns a plain object
|
||||||
|
* `{$type: 'blob', ref, mimeType, size}` (with `ref` a parsed CID), not a
|
||||||
|
* `BlobRef` class instance. The structural `isBlobRef` guard must treat it
|
||||||
|
* exactly like the class instance so the CID is unchanged. Under the
|
||||||
|
* pre-change `instanceof` code this case already matches because the plain
|
||||||
|
* object walks through `prepareForHashing` unchanged and DAG-CBOR encodes
|
||||||
|
* its CID `ref` the same way `.ipld()` does.
|
||||||
|
*/
|
||||||
|
const blob = {
|
||||||
|
$type: 'blob' as const,
|
||||||
|
ref: CID.parse(BLOB_CID),
|
||||||
|
mimeType: 'image/jpeg',
|
||||||
|
size: 12345,
|
||||||
|
}
|
||||||
|
expect(await computeCid(postWithImageBlob(blob))).toBe(
|
||||||
|
'bafyreiem7g6vja66nebr7he4fshfnlyndyldbvle2n265oixscmepjcbii',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('case 3: three-post thread chains reply StrongRef CIDs', async () => {
|
||||||
|
const did = 'did:plc:abc123'
|
||||||
|
const base = new Date('2024-01-01T00:00:00.000Z')
|
||||||
|
const golden = [
|
||||||
|
'bafyreig62rxs34h5rvznfrracwkjlfgad5b25qxglp2hcziqdfas2nw2ee',
|
||||||
|
'bafyreicxcj2tq5jrh5jcaczg3eli5cvxitgzu7kpu3fm5v3njq2byjxirq',
|
||||||
|
'bafyreigvaswuhlpd7dllja2xrqswhqbruyv2kar7mvbn7gdm5ldzu6vkti',
|
||||||
|
]
|
||||||
|
|
||||||
|
let reply: app.bsky.feed.post.Main['reply'] | undefined
|
||||||
|
for (let i = 0; i < 3; i++) {
|
||||||
|
const now = new Date(base.getTime() + i)
|
||||||
|
const uri = `at://${did}/app.bsky.feed.post/rkey${i}`
|
||||||
|
const record = {
|
||||||
|
$type: 'app.bsky.feed.post',
|
||||||
|
createdAt: now.toISOString(),
|
||||||
|
text: `post ${i}`,
|
||||||
|
reply,
|
||||||
|
} as app.bsky.feed.post.Main
|
||||||
|
const cid = await computeCid(record)
|
||||||
|
expect(cid).toBe(golden[i])
|
||||||
|
const ref = {cid, uri} as com.atproto.repo.strongRef.Main
|
||||||
|
reply = {root: reply?.root ?? ref, parent: ref}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
import {sha256} from 'js-sha256'
|
||||||
|
import {CID} from 'multiformats/cid'
|
||||||
|
import * as Hasher from 'multiformats/hashes/hasher'
|
||||||
|
|
||||||
|
import {app} from '#/lexicons'
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Client-side CID computation for post records, extracted from the post
|
||||||
|
* pipeline so it can be unit-tested in isolation (importing the pipeline pulls
|
||||||
|
* in the native gallery/media chain). See `computeCid.test.ts` for the golden
|
||||||
|
* -CID regression fixtures that gate any change to this serialization.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// The built-in hashing functions from multiformats (`multiformats/hashes/sha2`)
|
||||||
|
// are meant for Node.js, this is the cross-platform equivalent.
|
||||||
|
const mf_sha256 = Hasher.from({
|
||||||
|
name: 'sha2-256',
|
||||||
|
code: 0x12,
|
||||||
|
encode: input => {
|
||||||
|
const digest = sha256.arrayBuffer(input)
|
||||||
|
return new Uint8Array(digest)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
export async function computeCid(
|
||||||
|
record: app.bsky.feed.post.Main,
|
||||||
|
): Promise<string> {
|
||||||
|
/*
|
||||||
|
* Lazily loaded since it's only needed when posting a thread, and its
|
||||||
|
* `cborg` dependency is ~190KB that would otherwise be in the initial
|
||||||
|
* web bundle.
|
||||||
|
*/
|
||||||
|
const dcbor = await importDagCbor()
|
||||||
|
// IMPORTANT: `prepareObject` prepares the record to be hashed by removing
|
||||||
|
// fields with undefined value, and converting BlobRef instances to the
|
||||||
|
// right IPLD representation.
|
||||||
|
const prepared = prepareForHashing(record)
|
||||||
|
// 1. Encode the record into DAG-CBOR format
|
||||||
|
const encoded = dcbor.encode(prepared)
|
||||||
|
// 2. Hash the record in SHA-256 (code 0x12)
|
||||||
|
const digest = await mf_sha256.digest(encoded)
|
||||||
|
// 3. Create a CIDv1, specifying DAG-CBOR as content (code 0x71)
|
||||||
|
const cid = CID.createV1(0x71, digest)
|
||||||
|
// 4. Get the Base32 representation of the CID (`b` prefix)
|
||||||
|
return cid.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True for a plain-JSON lexicon blob, the shape lex `uploadBlob` now returns
|
||||||
|
* (`{$type: 'blob', ref, mimeType, size}` with `ref` a parsed CID). Replaces
|
||||||
|
* the old `instanceof BlobRef` check, since lex blobs are plain objects, not
|
||||||
|
* class instances (design section F).
|
||||||
|
*/
|
||||||
|
function isBlobRef(v: unknown): boolean {
|
||||||
|
if (v == null || typeof v !== 'object') return false
|
||||||
|
const o = v as Record<string, unknown>
|
||||||
|
return o.$type === 'blob' && 'ref' in o && 'mimeType' in o
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True for a legacy `@atproto/api` `BlobRef` class instance. During the
|
||||||
|
* migration the video embed path still yields these (its blob comes from the
|
||||||
|
* not-yet-migrated `app.bsky.video.getJobStatus` bridge call), so we must keep
|
||||||
|
* handling them here even though the composer's own uploads are now plain lex
|
||||||
|
* blobs. A class instance is duck-typed by its `ipld()` method plus the
|
||||||
|
* `ref`/`mimeType` fields; it has NO `$type` and a non-plain prototype, so it
|
||||||
|
* would otherwise slip past both `isBlobRef` and `isPlainObject` and be encoded
|
||||||
|
* wrong - silently breaking video reply-chain CIDs.
|
||||||
|
*/
|
||||||
|
function isBlobRefInstance(
|
||||||
|
v: unknown,
|
||||||
|
): v is {ipld: () => unknown; ref: unknown; mimeType: unknown} {
|
||||||
|
if (v == null || typeof v !== 'object') return false
|
||||||
|
const o = v as Record<string, unknown>
|
||||||
|
return typeof o.ipld === 'function' && 'ref' in o && 'mimeType' in o
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a transformed version of the object for use in DAG-CBOR.
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
function prepareForHashing(v: any): any {
|
||||||
|
/*
|
||||||
|
* A plain-JSON lex blob is already in the right IPLD shape (its `ref` is a
|
||||||
|
* parsed CID that DAG-CBOR encodes as a CID link), so pass it through
|
||||||
|
* untouched.
|
||||||
|
*/
|
||||||
|
if (isBlobRef(v)) {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A legacy `BlobRef` class instance must be converted via `ipld()` to the
|
||||||
|
* plain `{$type, ref, mimeType, size}` object; encoding the instance directly
|
||||||
|
* would emit its internal `original` field and omit `$type`, producing the
|
||||||
|
* wrong CID. `ipld()` returns exactly what `isBlobRef` accepts above.
|
||||||
|
*/
|
||||||
|
if (isBlobRefInstance(v)) {
|
||||||
|
return v.ipld()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Walk through arrays
|
||||||
|
if (Array.isArray(v)) {
|
||||||
|
let pure = true
|
||||||
|
const mapped = v.map(value => {
|
||||||
|
if (value !== (value = prepareForHashing(value))) {
|
||||||
|
pure = false
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
})
|
||||||
|
return pure ? v : mapped
|
||||||
|
}
|
||||||
|
|
||||||
|
// Walk through plain objects
|
||||||
|
if (isPlainObject(v)) {
|
||||||
|
const rec = v as Record<string, unknown>
|
||||||
|
const obj: Record<string, unknown> = {}
|
||||||
|
let pure = true
|
||||||
|
for (const key in rec) {
|
||||||
|
let value = rec[key]
|
||||||
|
// `value` is undefined
|
||||||
|
if (value === undefined) {
|
||||||
|
pure = false
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// `prepareObject` returned a value that's different from what we had before
|
||||||
|
if (value !== (value = prepareForHashing(value))) {
|
||||||
|
pure = false
|
||||||
|
}
|
||||||
|
obj[key] = value
|
||||||
|
}
|
||||||
|
// Return as is if we haven't needed to tamper with anything
|
||||||
|
return pure ? v : obj
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
function isPlainObject(v: any): boolean {
|
||||||
|
if (typeof v !== 'object' || v === null) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const proto = Object.getPrototypeOf(v)
|
||||||
|
return proto === Object.prototype || proto === null
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load `@ipld/dag-cbor` on demand. The dynamic `import()` lets web bundlers
|
||||||
|
* emit it (and its ~190KB `cborg` dependency) as a separate chunk that only
|
||||||
|
* loads when posting a thread. Under jest (which runs without
|
||||||
|
* `--experimental-vm-modules`) dynamic import throws, so we fall back to a
|
||||||
|
* lazy `require`, which resolves through the test moduleNameMapper.
|
||||||
|
*/
|
||||||
|
function importDagCbor(): Promise<typeof import('@ipld/dag-cbor')> {
|
||||||
|
if (process.env.NODE_ENV === 'test') {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||||
|
return Promise.resolve(require('@ipld/dag-cbor'))
|
||||||
|
}
|
||||||
|
return import('@ipld/dag-cbor')
|
||||||
|
}
|
||||||
+24
-28
@@ -1,23 +1,21 @@
|
|||||||
import {
|
import {type Client} from '@atproto/lex-client'
|
||||||
AppBskyFeedDefs,
|
|
||||||
type AppBskyFeedGetAuthorFeed as GetAuthorFeed,
|
|
||||||
} from '@atproto/api'
|
|
||||||
|
|
||||||
import {type SessionAgent} from '#/state/session'
|
import {app} from '#/lexicons'
|
||||||
|
import * as bsky from '#/types/bsky'
|
||||||
import {type FeedAPI, type FeedAPIResponse} from './types'
|
import {type FeedAPI, type FeedAPIResponse} from './types'
|
||||||
|
|
||||||
export class AuthorFeedAPI implements FeedAPI {
|
export class AuthorFeedAPI implements FeedAPI {
|
||||||
agent: SessionAgent
|
client: Client
|
||||||
_params: GetAuthorFeed.QueryParams
|
_params: app.bsky.feed.getAuthorFeed.$Params
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
agent,
|
client,
|
||||||
feedParams,
|
feedParams,
|
||||||
}: {
|
}: {
|
||||||
agent: SessionAgent
|
client: Client
|
||||||
feedParams: GetAuthorFeed.QueryParams
|
feedParams: app.bsky.feed.getAuthorFeed.$Params
|
||||||
}) {
|
}) {
|
||||||
this.agent = agent
|
this.client = client
|
||||||
this._params = feedParams
|
this._params = feedParams
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,12 +25,12 @@ export class AuthorFeedAPI implements FeedAPI {
|
|||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|
||||||
async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> {
|
async peekLatest(): Promise<app.bsky.feed.defs.FeedViewPost> {
|
||||||
const res = await this.agent.getAuthorFeed({
|
const res = await this.client.call(app.bsky.feed.getAuthorFeed, {
|
||||||
...this.params,
|
...this.params,
|
||||||
limit: 1,
|
limit: 1,
|
||||||
})
|
})
|
||||||
return res.data.feed[0]
|
return res.feed[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch({
|
async fetch({
|
||||||
@@ -42,28 +40,26 @@ export class AuthorFeedAPI implements FeedAPI {
|
|||||||
cursor: string | undefined
|
cursor: string | undefined
|
||||||
limit: number
|
limit: number
|
||||||
}): Promise<FeedAPIResponse> {
|
}): Promise<FeedAPIResponse> {
|
||||||
const res = await this.agent.getAuthorFeed({
|
const res = await this.client.call(app.bsky.feed.getAuthorFeed, {
|
||||||
...this.params,
|
...this.params,
|
||||||
cursor,
|
cursor,
|
||||||
limit,
|
limit,
|
||||||
})
|
})
|
||||||
if (res.success) {
|
|
||||||
return {
|
return {
|
||||||
cursor: res.data.cursor,
|
cursor: res.cursor,
|
||||||
feed: this._filter(res.data.feed),
|
feed: this._filter(res.feed),
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
feed: [],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_filter(feed: AppBskyFeedDefs.FeedViewPost[]) {
|
_filter(feed: app.bsky.feed.defs.FeedViewPost[]) {
|
||||||
if (this.params.filter === 'posts_and_author_threads') {
|
if (this.params.filter === 'posts_and_author_threads') {
|
||||||
return feed.filter(post => {
|
return feed.filter(post => {
|
||||||
const isReply = post.reply
|
const isReply = post.reply
|
||||||
const isRepost = AppBskyFeedDefs.isReasonRepost(post.reason)
|
const isRepost = bsky.isType(
|
||||||
const isPin = AppBskyFeedDefs.isReasonPin(post.reason)
|
app.bsky.feed.defs.reasonRepost,
|
||||||
|
post.reason,
|
||||||
|
)
|
||||||
|
const isPin = bsky.isType(app.bsky.feed.defs.reasonPin, post.reason)
|
||||||
if (!isReply) return true
|
if (!isReply) return true
|
||||||
if (isRepost || isPin) return true
|
if (isRepost || isPin) return true
|
||||||
return isReply && isAuthorReplyChain(this.params.actor, post, feed)
|
return isReply && isAuthorReplyChain(this.params.actor, post, feed)
|
||||||
@@ -76,15 +72,15 @@ export class AuthorFeedAPI implements FeedAPI {
|
|||||||
|
|
||||||
function isAuthorReplyChain(
|
function isAuthorReplyChain(
|
||||||
actor: string,
|
actor: string,
|
||||||
post: AppBskyFeedDefs.FeedViewPost,
|
post: app.bsky.feed.defs.FeedViewPost,
|
||||||
posts: AppBskyFeedDefs.FeedViewPost[],
|
posts: app.bsky.feed.defs.FeedViewPost[],
|
||||||
): boolean {
|
): boolean {
|
||||||
// current post is by a different user (shouldn't happen)
|
// current post is by a different user (shouldn't happen)
|
||||||
if (post.post.author.did !== actor) return false
|
if (post.post.author.did !== actor) return false
|
||||||
|
|
||||||
const replyParent = post.reply?.parent
|
const replyParent = post.reply?.parent
|
||||||
|
|
||||||
if (AppBskyFeedDefs.isPostView(replyParent)) {
|
if (bsky.isType(app.bsky.feed.defs.postView, replyParent)) {
|
||||||
// reply parent is by a different user
|
// reply parent is by a different user
|
||||||
if (replyParent.author.did !== actor) return false
|
if (replyParent.author.did !== actor) return false
|
||||||
|
|
||||||
|
|||||||
+51
-36
@@ -1,47 +1,53 @@
|
|||||||
import {
|
import {lexParse} from '@atproto/lex'
|
||||||
type AppBskyFeedDefs,
|
import {Client} from '@atproto/lex-client'
|
||||||
type AppBskyFeedGetFeed as GetCustomFeed,
|
|
||||||
AtpAgent,
|
|
||||||
jsonStringToLex,
|
|
||||||
} from '@atproto/api'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getAppLanguageAsContentLanguage,
|
getAppLanguageAsContentLanguage,
|
||||||
getContentLanguages,
|
getContentLanguages,
|
||||||
} from '#/state/preferences/languages'
|
} from '#/state/preferences/languages'
|
||||||
import {type SessionAgent} from '#/state/session'
|
import {app} from '#/lexicons'
|
||||||
import {type FeedAPI, type FeedAPIResponse} from './types'
|
import {type FeedAPI, type FeedAPIResponse} from './types'
|
||||||
import {createBskyTopicsHeader, isBlueskyOwnedFeed} from './utils'
|
import {createBskyTopicsHeader, isBlueskyOwnedFeed} from './utils'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Input params for {@link CustomFeedAPI}. The generated `$Params` type reflects
|
||||||
|
* post-parse output, where `limit` (which has a lexicon default) is required;
|
||||||
|
* callers supply only `feed` and let `limit`/`cursor` come from `fetch`.
|
||||||
|
*/
|
||||||
|
type CustomFeedParams = {feed: app.bsky.feed.getFeed.$Params['feed']} & Partial<
|
||||||
|
Omit<app.bsky.feed.getFeed.$Params, 'feed'>
|
||||||
|
>
|
||||||
|
|
||||||
export class CustomFeedAPI implements FeedAPI {
|
export class CustomFeedAPI implements FeedAPI {
|
||||||
agent: SessionAgent
|
client: Client
|
||||||
params: GetCustomFeed.QueryParams
|
params: CustomFeedParams
|
||||||
userInterests?: string
|
userInterests?: string
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
agent,
|
client,
|
||||||
feedParams,
|
feedParams,
|
||||||
userInterests,
|
userInterests,
|
||||||
}: {
|
}: {
|
||||||
agent: SessionAgent
|
client: Client
|
||||||
feedParams: GetCustomFeed.QueryParams
|
feedParams: CustomFeedParams
|
||||||
userInterests?: string
|
userInterests?: string
|
||||||
}) {
|
}) {
|
||||||
this.agent = agent
|
this.client = client
|
||||||
this.params = feedParams
|
this.params = feedParams
|
||||||
this.userInterests = userInterests
|
this.userInterests = userInterests
|
||||||
}
|
}
|
||||||
|
|
||||||
async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> {
|
async peekLatest(): Promise<app.bsky.feed.defs.FeedViewPost> {
|
||||||
const contentLangs = getContentLanguages().join(',')
|
const contentLangs = getContentLanguages().join(',')
|
||||||
const res = await this.agent.app.bsky.feed.getFeed(
|
const res = await this.client.call(
|
||||||
|
app.bsky.feed.getFeed,
|
||||||
{
|
{
|
||||||
...this.params,
|
...this.params,
|
||||||
limit: 1,
|
limit: 1,
|
||||||
},
|
},
|
||||||
{headers: {'Accept-Language': contentLangs}},
|
{headers: {'Accept-Language': contentLangs}},
|
||||||
)
|
)
|
||||||
return res.data.feed[0]
|
return res.feed[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch({
|
async fetch({
|
||||||
@@ -52,11 +58,14 @@ export class CustomFeedAPI implements FeedAPI {
|
|||||||
limit: number
|
limit: number
|
||||||
}): Promise<FeedAPIResponse> {
|
}): Promise<FeedAPIResponse> {
|
||||||
const contentLangs = getContentLanguages().join(',')
|
const contentLangs = getContentLanguages().join(',')
|
||||||
const agent = this.agent
|
|
||||||
const isBlueskyOwned = isBlueskyOwnedFeed(this.params.feed)
|
const isBlueskyOwned = isBlueskyOwnedFeed(this.params.feed)
|
||||||
|
|
||||||
const res = agent.did
|
let feed: app.bsky.feed.defs.FeedViewPost[]
|
||||||
? await this.agent.app.bsky.feed.getFeed(
|
let resCursor: string | undefined
|
||||||
|
|
||||||
|
if (this.client.did) {
|
||||||
|
const res = await this.client.call(
|
||||||
|
app.bsky.feed.getFeed,
|
||||||
{
|
{
|
||||||
...this.params,
|
...this.params,
|
||||||
cursor,
|
cursor,
|
||||||
@@ -71,22 +80,27 @@ export class CustomFeedAPI implements FeedAPI {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: await loggedOutFetch({...this.params, cursor, limit})
|
feed = res.feed
|
||||||
if (res.success) {
|
resCursor = res.cursor
|
||||||
|
} else {
|
||||||
|
const res = await loggedOutFetch({...this.params, cursor, limit})
|
||||||
|
if (!res.success) {
|
||||||
|
return {feed: []}
|
||||||
|
}
|
||||||
|
feed = res.data.feed
|
||||||
|
resCursor = res.data.cursor
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE
|
// NOTE
|
||||||
// some custom feeds fail to enforce the pagination limit
|
// some custom feeds fail to enforce the pagination limit
|
||||||
// so we manually truncate here
|
// so we manually truncate here
|
||||||
// -prf
|
// -prf
|
||||||
if (res.data.feed.length > limit) {
|
if (feed.length > limit) {
|
||||||
res.data.feed = res.data.feed.slice(0, limit)
|
feed = feed.slice(0, limit)
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
cursor: res.data.feed.length ? res.data.cursor : undefined,
|
cursor: feed.length ? resCursor : undefined,
|
||||||
feed: res.data.feed,
|
feed,
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
feed: [],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,15 +120,16 @@ async function loggedOutFetch({
|
|||||||
feed: string
|
feed: string
|
||||||
limit: number
|
limit: number
|
||||||
cursor?: string
|
cursor?: string
|
||||||
}) {
|
}): Promise<{success: boolean; data: app.bsky.feed.getFeed.$OutputBody}> {
|
||||||
let contentLangs = getAppLanguageAsContentLanguage()
|
let contentLangs = getAppLanguageAsContentLanguage()
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Copied from our root `Agent` class
|
* Copied from our root `Agent` class. The global (`;redact`-suffixed) app
|
||||||
* @see https://github.com/bluesky-social/atproto/blob/60df3fc652b00cdff71dd9235d98a7a4bb828f05/packages/api/src/agent.ts#L120
|
* labelers are kept on the lex `Client` static (synced in
|
||||||
|
* `#/state/session/moderation`), replacing the old `AtpAgent.appLabelers`.
|
||||||
*/
|
*/
|
||||||
const labelersHeader = {
|
const labelersHeader = {
|
||||||
'atproto-accept-labelers': AtpAgent.appLabelers
|
'atproto-accept-labelers': Client.appLabelers
|
||||||
.map(l => `${l};redact`)
|
.map(l => `${l};redact`)
|
||||||
.join(', '),
|
.join(', '),
|
||||||
}
|
}
|
||||||
@@ -130,7 +145,7 @@ async function loggedOutFetch({
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
let data = res.ok
|
let data = res.ok
|
||||||
? (jsonStringToLex(await res.text()) as GetCustomFeed.OutputSchema)
|
? (lexParse(await res.text()) as app.bsky.feed.getFeed.$OutputBody)
|
||||||
: null
|
: null
|
||||||
if (data?.feed?.length) {
|
if (data?.feed?.length) {
|
||||||
return {
|
return {
|
||||||
@@ -147,7 +162,7 @@ async function loggedOutFetch({
|
|||||||
{method: 'GET', headers: {'Accept-Language': '', ...labelersHeader}},
|
{method: 'GET', headers: {'Accept-Language': '', ...labelersHeader}},
|
||||||
)
|
)
|
||||||
data = res.ok
|
data = res.ok
|
||||||
? (jsonStringToLex(await res.text()) as GetCustomFeed.OutputSchema)
|
? (lexParse(await res.text()) as app.bsky.feed.getFeed.$OutputBody)
|
||||||
: null
|
: null
|
||||||
if (data?.feed?.length) {
|
if (data?.feed?.length) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,21 +1,28 @@
|
|||||||
import {type AppBskyFeedDefs} from '@atproto/api'
|
import {type Client} from '@atproto/lex-client'
|
||||||
|
|
||||||
import {DEMO_FEED} from '#/lib/demo'
|
import {DEMO_FEED} from '#/lib/demo'
|
||||||
import {type SessionAgent} from '#/state/session'
|
import {type app} from '#/lexicons'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
import {type FeedAPI, type FeedAPIResponse} from './types'
|
import {type FeedAPI, type FeedAPIResponse} from './types'
|
||||||
|
|
||||||
export class DemoFeedAPI implements FeedAPI {
|
export class DemoFeedAPI implements FeedAPI {
|
||||||
agent: SessionAgent
|
client: Client
|
||||||
|
|
||||||
constructor({agent}: {agent: SessionAgent}) {
|
constructor({client}: {client: Client}) {
|
||||||
this.agent = agent
|
this.client = client
|
||||||
}
|
}
|
||||||
|
|
||||||
async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> {
|
async peekLatest(): Promise<app.bsky.feed.defs.FeedViewPost> {
|
||||||
return DEMO_FEED.feed[0]
|
/*
|
||||||
|
* TODO(phase4): drop this cast once `#/lib/demo` (DEMO_FEED) sources its
|
||||||
|
* feed items from `#/lexicons`. Its records are still typed against the old
|
||||||
|
* `@atproto/api` FeedViewPost, which does not assign to the branded lexicon
|
||||||
|
* type this method must return.
|
||||||
|
*/
|
||||||
|
return toLex(DEMO_FEED.feed[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch(): Promise<FeedAPIResponse> {
|
async fetch(): Promise<FeedAPIResponse> {
|
||||||
return DEMO_FEED
|
return toLex(DEMO_FEED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import {type AppBskyFeedDefs} from '@atproto/api'
|
import {type Client} from '@atproto/lex-client'
|
||||||
|
|
||||||
import {type SessionAgent} from '#/state/session'
|
import {app} from '#/lexicons'
|
||||||
import {type FeedAPI, type FeedAPIResponse} from './types'
|
import {type FeedAPI, type FeedAPIResponse} from './types'
|
||||||
|
|
||||||
export class FollowingFeedAPI implements FeedAPI {
|
export class FollowingFeedAPI implements FeedAPI {
|
||||||
agent: SessionAgent
|
client: Client
|
||||||
|
|
||||||
constructor({agent}: {agent: SessionAgent}) {
|
constructor({client}: {client: Client}) {
|
||||||
this.agent = agent
|
this.client = client
|
||||||
}
|
}
|
||||||
|
|
||||||
async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> {
|
async peekLatest(): Promise<app.bsky.feed.defs.FeedViewPost> {
|
||||||
const res = await this.agent.getTimeline({
|
const res = await this.client.call(app.bsky.feed.getTimeline, {
|
||||||
limit: 1,
|
limit: 1,
|
||||||
})
|
})
|
||||||
return res.data.feed[0]
|
return res.feed[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch({
|
async fetch({
|
||||||
@@ -24,18 +24,13 @@ export class FollowingFeedAPI implements FeedAPI {
|
|||||||
cursor: string | undefined
|
cursor: string | undefined
|
||||||
limit: number
|
limit: number
|
||||||
}): Promise<FeedAPIResponse> {
|
}): Promise<FeedAPIResponse> {
|
||||||
const res = await this.agent.getTimeline({
|
const res = await this.client.call(app.bsky.feed.getTimeline, {
|
||||||
cursor,
|
cursor,
|
||||||
limit,
|
limit,
|
||||||
})
|
})
|
||||||
if (res.success) {
|
|
||||||
return {
|
return {
|
||||||
cursor: res.data.cursor,
|
cursor: res.cursor,
|
||||||
feed: res.data.feed,
|
feed: res.feed,
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
feed: [],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-16
@@ -1,7 +1,8 @@
|
|||||||
import {type AppBskyFeedDefs} from '@atproto/api'
|
import {type Client} from '@atproto/lex-client'
|
||||||
|
import {type AtUriString} from '@atproto/syntax'
|
||||||
|
|
||||||
import {PROD_DEFAULT_FEED} from '#/lib/constants'
|
import {PROD_DEFAULT_FEED} from '#/lib/constants'
|
||||||
import {type SessionAgent} from '#/state/session'
|
import {type app} from '#/lexicons'
|
||||||
import {CustomFeedAPI} from './custom'
|
import {CustomFeedAPI} from './custom'
|
||||||
import {FollowingFeedAPI} from './following'
|
import {FollowingFeedAPI} from './following'
|
||||||
import {type FeedAPI, type FeedAPIResponse} from './types'
|
import {type FeedAPI, type FeedAPIResponse} from './types'
|
||||||
@@ -14,7 +15,11 @@ import {type FeedAPI, type FeedAPIResponse} from './types'
|
|||||||
// we use this fallback marker post to drive this instead. see Feed.tsx
|
// we use this fallback marker post to drive this instead. see Feed.tsx
|
||||||
// for the usage.
|
// for the usage.
|
||||||
// -prf
|
// -prf
|
||||||
export const FALLBACK_MARKER_POST: AppBskyFeedDefs.FeedViewPost = {
|
/*
|
||||||
|
* A sentinel post whose fields intentionally violate the branded lexicon
|
||||||
|
* formats (`uri`, `did`, `indexedAt`), so it is asserted into the view type.
|
||||||
|
*/
|
||||||
|
export const FALLBACK_MARKER_POST: app.bsky.feed.defs.FeedViewPost = {
|
||||||
post: {
|
post: {
|
||||||
uri: 'fallback-marker-post',
|
uri: 'fallback-marker-post',
|
||||||
cid: 'fake',
|
cid: 'fake',
|
||||||
@@ -25,10 +30,10 @@ export const FALLBACK_MARKER_POST: AppBskyFeedDefs.FeedViewPost = {
|
|||||||
},
|
},
|
||||||
indexedAt: new Date().toISOString(),
|
indexedAt: new Date().toISOString(),
|
||||||
},
|
},
|
||||||
}
|
} as unknown as app.bsky.feed.defs.FeedViewPost
|
||||||
|
|
||||||
export class HomeFeedAPI implements FeedAPI {
|
export class HomeFeedAPI implements FeedAPI {
|
||||||
agent: SessionAgent
|
client: Client
|
||||||
following: FollowingFeedAPI
|
following: FollowingFeedAPI
|
||||||
discover: CustomFeedAPI
|
discover: CustomFeedAPI
|
||||||
usingDiscover = false
|
usingDiscover = false
|
||||||
@@ -37,32 +42,32 @@ export class HomeFeedAPI implements FeedAPI {
|
|||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
userInterests,
|
userInterests,
|
||||||
agent,
|
client,
|
||||||
}: {
|
}: {
|
||||||
userInterests?: string
|
userInterests?: string
|
||||||
agent: SessionAgent
|
client: Client
|
||||||
}) {
|
}) {
|
||||||
this.agent = agent
|
this.client = client
|
||||||
this.following = new FollowingFeedAPI({agent})
|
this.following = new FollowingFeedAPI({client})
|
||||||
this.discover = new CustomFeedAPI({
|
this.discover = new CustomFeedAPI({
|
||||||
agent,
|
client,
|
||||||
feedParams: {feed: PROD_DEFAULT_FEED('whats-hot')},
|
feedParams: {feed: PROD_DEFAULT_FEED('whats-hot') as AtUriString},
|
||||||
})
|
})
|
||||||
this.userInterests = userInterests
|
this.userInterests = userInterests
|
||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
this.following = new FollowingFeedAPI({agent: this.agent})
|
this.following = new FollowingFeedAPI({client: this.client})
|
||||||
this.discover = new CustomFeedAPI({
|
this.discover = new CustomFeedAPI({
|
||||||
agent: this.agent,
|
client: this.client,
|
||||||
feedParams: {feed: PROD_DEFAULT_FEED('whats-hot')},
|
feedParams: {feed: PROD_DEFAULT_FEED('whats-hot') as AtUriString},
|
||||||
userInterests: this.userInterests,
|
userInterests: this.userInterests,
|
||||||
})
|
})
|
||||||
this.usingDiscover = false
|
this.usingDiscover = false
|
||||||
this.itemCursor = 0
|
this.itemCursor = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> {
|
async peekLatest(): Promise<app.bsky.feed.defs.FeedViewPost> {
|
||||||
if (this.usingDiscover) {
|
if (this.usingDiscover) {
|
||||||
return this.discover.peekLatest()
|
return this.discover.peekLatest()
|
||||||
}
|
}
|
||||||
@@ -81,7 +86,7 @@ export class HomeFeedAPI implements FeedAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let returnCursor
|
let returnCursor
|
||||||
let posts: AppBskyFeedDefs.FeedViewPost[] = []
|
let posts: app.bsky.feed.defs.FeedViewPost[] = []
|
||||||
|
|
||||||
if (!this.usingDiscover) {
|
if (!this.usingDiscover) {
|
||||||
const res = await this.following.fetch({cursor, limit})
|
const res = await this.following.fetch({cursor, limit})
|
||||||
|
|||||||
+15
-23
@@ -1,32 +1,29 @@
|
|||||||
import {
|
import {type Client} from '@atproto/lex-client'
|
||||||
type AppBskyFeedDefs,
|
|
||||||
type AppBskyFeedGetActorLikes as GetActorLikes,
|
|
||||||
} from '@atproto/api'
|
|
||||||
|
|
||||||
import {type SessionAgent} from '#/state/session'
|
import {app} from '#/lexicons'
|
||||||
import {type FeedAPI, type FeedAPIResponse} from './types'
|
import {type FeedAPI, type FeedAPIResponse} from './types'
|
||||||
|
|
||||||
export class LikesFeedAPI implements FeedAPI {
|
export class LikesFeedAPI implements FeedAPI {
|
||||||
agent: SessionAgent
|
client: Client
|
||||||
params: GetActorLikes.QueryParams
|
params: app.bsky.feed.getActorLikes.$Params
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
agent,
|
client,
|
||||||
feedParams,
|
feedParams,
|
||||||
}: {
|
}: {
|
||||||
agent: SessionAgent
|
client: Client
|
||||||
feedParams: GetActorLikes.QueryParams
|
feedParams: app.bsky.feed.getActorLikes.$Params
|
||||||
}) {
|
}) {
|
||||||
this.agent = agent
|
this.client = client
|
||||||
this.params = feedParams
|
this.params = feedParams
|
||||||
}
|
}
|
||||||
|
|
||||||
async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> {
|
async peekLatest(): Promise<app.bsky.feed.defs.FeedViewPost> {
|
||||||
const res = await this.agent.getActorLikes({
|
const res = await this.client.call(app.bsky.feed.getActorLikes, {
|
||||||
...this.params,
|
...this.params,
|
||||||
limit: 1,
|
limit: 1,
|
||||||
})
|
})
|
||||||
return res.data.feed[0]
|
return res.feed[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch({
|
async fetch({
|
||||||
@@ -36,21 +33,16 @@ export class LikesFeedAPI implements FeedAPI {
|
|||||||
cursor: string | undefined
|
cursor: string | undefined
|
||||||
limit: number
|
limit: number
|
||||||
}): Promise<FeedAPIResponse> {
|
}): Promise<FeedAPIResponse> {
|
||||||
const res = await this.agent.getActorLikes({
|
const res = await this.client.call(app.bsky.feed.getActorLikes, {
|
||||||
...this.params,
|
...this.params,
|
||||||
cursor,
|
cursor,
|
||||||
limit,
|
limit,
|
||||||
})
|
})
|
||||||
if (res.success) {
|
|
||||||
// HACKFIX: the API incorrectly returns a cursor when there are no items -sfn
|
// HACKFIX: the API incorrectly returns a cursor when there are no items -sfn
|
||||||
const isEmptyPage = res.data.feed.length === 0
|
const isEmptyPage = res.feed.length === 0
|
||||||
return {
|
return {
|
||||||
cursor: isEmptyPage ? undefined : res.data.cursor,
|
cursor: isEmptyPage ? undefined : res.cursor,
|
||||||
feed: res.data.feed,
|
feed: res.feed,
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
feed: [],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-22
@@ -1,32 +1,29 @@
|
|||||||
import {
|
import {type Client} from '@atproto/lex-client'
|
||||||
type Agent,
|
|
||||||
type AppBskyFeedDefs,
|
|
||||||
type AppBskyFeedGetListFeed as GetListFeed,
|
|
||||||
} from '@atproto/api'
|
|
||||||
|
|
||||||
|
import {app} from '#/lexicons'
|
||||||
import {type FeedAPI, type FeedAPIResponse} from './types'
|
import {type FeedAPI, type FeedAPIResponse} from './types'
|
||||||
|
|
||||||
export class ListFeedAPI implements FeedAPI {
|
export class ListFeedAPI implements FeedAPI {
|
||||||
agent: Agent
|
client: Client
|
||||||
params: GetListFeed.QueryParams
|
params: app.bsky.feed.getListFeed.$Params
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
agent,
|
client,
|
||||||
feedParams,
|
feedParams,
|
||||||
}: {
|
}: {
|
||||||
agent: Agent
|
client: Client
|
||||||
feedParams: GetListFeed.QueryParams
|
feedParams: app.bsky.feed.getListFeed.$Params
|
||||||
}) {
|
}) {
|
||||||
this.agent = agent
|
this.client = client
|
||||||
this.params = feedParams
|
this.params = feedParams
|
||||||
}
|
}
|
||||||
|
|
||||||
async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> {
|
async peekLatest(): Promise<app.bsky.feed.defs.FeedViewPost> {
|
||||||
const res = await this.agent.app.bsky.feed.getListFeed({
|
const res = await this.client.call(app.bsky.feed.getListFeed, {
|
||||||
...this.params,
|
...this.params,
|
||||||
limit: 1,
|
limit: 1,
|
||||||
})
|
})
|
||||||
return res.data.feed[0]
|
return res.feed[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch({
|
async fetch({
|
||||||
@@ -36,19 +33,14 @@ export class ListFeedAPI implements FeedAPI {
|
|||||||
cursor: string | undefined
|
cursor: string | undefined
|
||||||
limit: number
|
limit: number
|
||||||
}): Promise<FeedAPIResponse> {
|
}): Promise<FeedAPIResponse> {
|
||||||
const res = await this.agent.app.bsky.feed.getListFeed({
|
const res = await this.client.call(app.bsky.feed.getListFeed, {
|
||||||
...this.params,
|
...this.params,
|
||||||
cursor,
|
cursor,
|
||||||
limit,
|
limit,
|
||||||
})
|
})
|
||||||
if (res.success) {
|
|
||||||
return {
|
return {
|
||||||
cursor: res.data.cursor,
|
cursor: res.cursor,
|
||||||
feed: res.data.feed,
|
feed: res.feed,
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
feed: [],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+70
-44
@@ -1,4 +1,5 @@
|
|||||||
import {type AppBskyFeedDefs, type AppBskyFeedGetTimeline} from '@atproto/api'
|
import {type Client} from '@atproto/lex-client'
|
||||||
|
import {type AtUriString} from '@atproto/syntax'
|
||||||
import shuffle from 'lodash.shuffle'
|
import shuffle from 'lodash.shuffle'
|
||||||
|
|
||||||
import {bundleAsync} from '#/lib/async/bundle'
|
import {bundleAsync} from '#/lib/async/bundle'
|
||||||
@@ -6,7 +7,8 @@ import {timeout} from '#/lib/async/timeout'
|
|||||||
import {feedUriToHref} from '#/lib/strings/url-helpers'
|
import {feedUriToHref} from '#/lib/strings/url-helpers'
|
||||||
import {getContentLanguages} from '#/state/preferences/languages'
|
import {getContentLanguages} from '#/state/preferences/languages'
|
||||||
import {type FeedParams} from '#/state/queries/post-feed'
|
import {type FeedParams} from '#/state/queries/post-feed'
|
||||||
import {type SessionAgent} from '#/state/session'
|
import {app} from '#/lexicons'
|
||||||
|
import {toLex} from '#/types/bsky'
|
||||||
import {FeedTuner} from '../feed-manip'
|
import {FeedTuner} from '../feed-manip'
|
||||||
import {type FeedTunerFn} from '../feed-manip'
|
import {type FeedTunerFn} from '../feed-manip'
|
||||||
import {
|
import {
|
||||||
@@ -19,9 +21,21 @@ import {createBskyTopicsHeader, isBlueskyOwnedFeed} from './utils'
|
|||||||
const REQUEST_WAIT_MS = 500 // 500ms
|
const REQUEST_WAIT_MS = 500 // 500ms
|
||||||
const POST_AGE_CUTOFF = 60e3 * 60 * 24 // 24hours
|
const POST_AGE_CUTOFF = 60e3 * 60 * 24 // 24hours
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal result shape for a single feed page fetch. Lex `client.call`
|
||||||
|
* returns the response body directly (throwing on error), so we no longer
|
||||||
|
* carry the old `{success, headers, data}` wrapper - `success` here just
|
||||||
|
* distinguishes an empty/errored fetch from a populated one.
|
||||||
|
*/
|
||||||
|
type FeedPage = {
|
||||||
|
success: boolean
|
||||||
|
cursor?: string
|
||||||
|
feed: app.bsky.feed.defs.FeedViewPost[]
|
||||||
|
}
|
||||||
|
|
||||||
export class MergeFeedAPI implements FeedAPI {
|
export class MergeFeedAPI implements FeedAPI {
|
||||||
userInterests?: string
|
userInterests?: string
|
||||||
agent: SessionAgent
|
client: Client
|
||||||
params: FeedParams
|
params: FeedParams
|
||||||
feedTuners: FeedTunerFn[]
|
feedTuners: FeedTunerFn[]
|
||||||
following: MergeFeedSource_Following
|
following: MergeFeedSource_Following
|
||||||
@@ -31,29 +45,29 @@ export class MergeFeedAPI implements FeedAPI {
|
|||||||
sampleCursor = 0
|
sampleCursor = 0
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
agent,
|
client,
|
||||||
feedParams,
|
feedParams,
|
||||||
feedTuners,
|
feedTuners,
|
||||||
userInterests,
|
userInterests,
|
||||||
}: {
|
}: {
|
||||||
agent: SessionAgent
|
client: Client
|
||||||
feedParams: FeedParams
|
feedParams: FeedParams
|
||||||
feedTuners: FeedTunerFn[]
|
feedTuners: FeedTunerFn[]
|
||||||
userInterests?: string
|
userInterests?: string
|
||||||
}) {
|
}) {
|
||||||
this.agent = agent
|
this.client = client
|
||||||
this.params = feedParams
|
this.params = feedParams
|
||||||
this.feedTuners = feedTuners
|
this.feedTuners = feedTuners
|
||||||
this.userInterests = userInterests
|
this.userInterests = userInterests
|
||||||
this.following = new MergeFeedSource_Following({
|
this.following = new MergeFeedSource_Following({
|
||||||
agent: this.agent,
|
client: this.client,
|
||||||
feedTuners: this.feedTuners,
|
feedTuners: this.feedTuners,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
this.following = new MergeFeedSource_Following({
|
this.following = new MergeFeedSource_Following({
|
||||||
agent: this.agent,
|
client: this.client,
|
||||||
feedTuners: this.feedTuners,
|
feedTuners: this.feedTuners,
|
||||||
})
|
})
|
||||||
this.customFeeds = []
|
this.customFeeds = []
|
||||||
@@ -65,7 +79,7 @@ export class MergeFeedAPI implements FeedAPI {
|
|||||||
this.params.mergeFeedSources.map(
|
this.params.mergeFeedSources.map(
|
||||||
feedUri =>
|
feedUri =>
|
||||||
new MergeFeedSource_Custom({
|
new MergeFeedSource_Custom({
|
||||||
agent: this.agent,
|
client: this.client,
|
||||||
feedUri,
|
feedUri,
|
||||||
feedTuners: this.feedTuners,
|
feedTuners: this.feedTuners,
|
||||||
userInterests: this.userInterests,
|
userInterests: this.userInterests,
|
||||||
@@ -77,11 +91,11 @@ export class MergeFeedAPI implements FeedAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> {
|
async peekLatest(): Promise<app.bsky.feed.defs.FeedViewPost> {
|
||||||
const res = await this.agent.getTimeline({
|
const res = await this.client.call(app.bsky.feed.getTimeline, {
|
||||||
limit: 1,
|
limit: 1,
|
||||||
})
|
})
|
||||||
return res.data.feed[0]
|
return res.feed[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch({
|
async fetch({
|
||||||
@@ -124,7 +138,7 @@ export class MergeFeedAPI implements FeedAPI {
|
|||||||
await Promise.all(promises)
|
await Promise.all(promises)
|
||||||
|
|
||||||
// assemble a response by sampling from feeds with content
|
// assemble a response by sampling from feeds with content
|
||||||
const posts: AppBskyFeedDefs.FeedViewPost[] = []
|
const posts: app.bsky.feed.defs.FeedViewPost[] = []
|
||||||
while (posts.length < limit) {
|
while (posts.length < limit) {
|
||||||
let slice = this.sampleItem()
|
let slice = this.sampleItem()
|
||||||
if (slice[0]) {
|
if (slice[0]) {
|
||||||
@@ -172,21 +186,21 @@ export class MergeFeedAPI implements FeedAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MergeFeedSource {
|
class MergeFeedSource {
|
||||||
agent: SessionAgent
|
client: Client
|
||||||
feedTuners: FeedTunerFn[]
|
feedTuners: FeedTunerFn[]
|
||||||
sourceInfo: ReasonFeedSource | undefined
|
sourceInfo: ReasonFeedSource | undefined
|
||||||
cursor: string | undefined = undefined
|
cursor: string | undefined = undefined
|
||||||
queue: AppBskyFeedDefs.FeedViewPost[] = []
|
queue: app.bsky.feed.defs.FeedViewPost[] = []
|
||||||
hasMore = true
|
hasMore = true
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
agent,
|
client,
|
||||||
feedTuners,
|
feedTuners,
|
||||||
}: {
|
}: {
|
||||||
agent: SessionAgent
|
client: Client
|
||||||
feedTuners: FeedTunerFn[]
|
feedTuners: FeedTunerFn[]
|
||||||
}) {
|
}) {
|
||||||
this.agent = agent
|
this.client = client
|
||||||
this.feedTuners = feedTuners
|
this.feedTuners = feedTuners
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +212,7 @@ class MergeFeedSource {
|
|||||||
return this.hasMore && this.queue.length === 0
|
return this.hasMore && this.queue.length === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
take(n: number): AppBskyFeedDefs.FeedViewPost[] {
|
take(n: number): app.bsky.feed.defs.FeedViewPost[] {
|
||||||
return this.queue.splice(0, n)
|
return this.queue.splice(0, n)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,9 +223,9 @@ class MergeFeedSource {
|
|||||||
_fetchNextInner = bundleAsync(async (n: number) => {
|
_fetchNextInner = bundleAsync(async (n: number) => {
|
||||||
const res = await this._getFeed(this.cursor, n)
|
const res = await this._getFeed(this.cursor, n)
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
this.cursor = res.data.cursor
|
this.cursor = res.cursor
|
||||||
if (res.data.feed.length) {
|
if (res.feed.length) {
|
||||||
this.queue = this.queue.concat(res.data.feed)
|
this.queue = this.queue.concat(res.feed)
|
||||||
} else {
|
} else {
|
||||||
this.hasMore = false
|
this.hasMore = false
|
||||||
}
|
}
|
||||||
@@ -223,7 +237,7 @@ class MergeFeedSource {
|
|||||||
protected _getFeed(
|
protected _getFeed(
|
||||||
_cursor: string | undefined,
|
_cursor: string | undefined,
|
||||||
_limit: number,
|
_limit: number,
|
||||||
): Promise<AppBskyFeedGetTimeline.Response> {
|
): Promise<FeedPage> {
|
||||||
throw new Error('Must be overridden')
|
throw new Error('Must be overridden')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -238,39 +252,51 @@ class MergeFeedSource_Following extends MergeFeedSource {
|
|||||||
protected async _getFeed(
|
protected async _getFeed(
|
||||||
cursor: string | undefined,
|
cursor: string | undefined,
|
||||||
limit: number,
|
limit: number,
|
||||||
): Promise<AppBskyFeedGetTimeline.Response> {
|
): Promise<FeedPage> {
|
||||||
const res = await this.agent.getTimeline({cursor, limit})
|
const res = await this.client.call(app.bsky.feed.getTimeline, {
|
||||||
|
cursor,
|
||||||
|
limit,
|
||||||
|
})
|
||||||
// run the tuner pre-emptively to ensure better mixing
|
// run the tuner pre-emptively to ensure better mixing
|
||||||
const slices = this.tuner.tune(res.data.feed, {
|
const slices = this.tuner.tune(res.feed, {
|
||||||
dryRun: false,
|
dryRun: false,
|
||||||
})
|
})
|
||||||
res.data.feed = slices.map(slice => slice._feedPost)
|
return {
|
||||||
return res
|
success: true,
|
||||||
|
cursor: res.cursor,
|
||||||
|
/*
|
||||||
|
* TODO(phase4): drop the toLex once `#/lib/api/feed-manip` (FeedTuner)
|
||||||
|
* flips its FeedViewPost source from `@atproto/api` to `#/lexicons`. Its
|
||||||
|
* `_feedPost` is still the old-world view type, which does not assign to
|
||||||
|
* the branded lexicon type this page carries.
|
||||||
|
*/
|
||||||
|
feed: slices.map(slice => toLex(slice._feedPost)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MergeFeedSource_Custom extends MergeFeedSource {
|
class MergeFeedSource_Custom extends MergeFeedSource {
|
||||||
agent: SessionAgent
|
client: Client
|
||||||
minDate: Date
|
minDate: Date
|
||||||
feedUri: string
|
feedUri: string
|
||||||
userInterests?: string
|
userInterests?: string
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
agent,
|
client,
|
||||||
feedUri,
|
feedUri,
|
||||||
feedTuners,
|
feedTuners,
|
||||||
userInterests,
|
userInterests,
|
||||||
}: {
|
}: {
|
||||||
agent: SessionAgent
|
client: Client
|
||||||
feedUri: string
|
feedUri: string
|
||||||
feedTuners: FeedTunerFn[]
|
feedTuners: FeedTunerFn[]
|
||||||
userInterests?: string
|
userInterests?: string
|
||||||
}) {
|
}) {
|
||||||
super({
|
super({
|
||||||
agent,
|
client,
|
||||||
feedTuners,
|
feedTuners,
|
||||||
})
|
})
|
||||||
this.agent = agent
|
this.client = client
|
||||||
this.feedUri = feedUri
|
this.feedUri = feedUri
|
||||||
this.userInterests = userInterests
|
this.userInterests = userInterests
|
||||||
this.sourceInfo = {
|
this.sourceInfo = {
|
||||||
@@ -284,15 +310,16 @@ class MergeFeedSource_Custom extends MergeFeedSource {
|
|||||||
protected async _getFeed(
|
protected async _getFeed(
|
||||||
cursor: string | undefined,
|
cursor: string | undefined,
|
||||||
limit: number,
|
limit: number,
|
||||||
): Promise<AppBskyFeedGetTimeline.Response> {
|
): Promise<FeedPage> {
|
||||||
try {
|
try {
|
||||||
const contentLangs = getContentLanguages().join(',')
|
const contentLangs = getContentLanguages().join(',')
|
||||||
const isBlueskyOwned = isBlueskyOwnedFeed(this.feedUri)
|
const isBlueskyOwned = isBlueskyOwnedFeed(this.feedUri)
|
||||||
const res = await this.agent.app.bsky.feed.getFeed(
|
const res = await this.client.call(
|
||||||
|
app.bsky.feed.getFeed,
|
||||||
{
|
{
|
||||||
cursor,
|
cursor,
|
||||||
limit,
|
limit,
|
||||||
feed: this.feedUri,
|
feed: this.feedUri as AtUriString,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
@@ -303,26 +330,25 @@ class MergeFeedSource_Custom extends MergeFeedSource {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
let feed = res.feed
|
||||||
// NOTE
|
// NOTE
|
||||||
// some custom feeds fail to enforce the pagination limit
|
// some custom feeds fail to enforce the pagination limit
|
||||||
// so we manually truncate here
|
// so we manually truncate here
|
||||||
// -prf
|
// -prf
|
||||||
if (limit && res.data.feed.length > limit) {
|
if (limit && feed.length > limit) {
|
||||||
res.data.feed = res.data.feed.slice(0, limit)
|
feed = feed.slice(0, limit)
|
||||||
}
|
}
|
||||||
// filter out older posts
|
// filter out older posts
|
||||||
res.data.feed = res.data.feed.filter(
|
feed = feed.filter(post => new Date(post.post.indexedAt) > this.minDate)
|
||||||
post => new Date(post.post.indexedAt) > this.minDate,
|
|
||||||
)
|
|
||||||
// attach source info
|
// attach source info
|
||||||
for (const post of res.data.feed) {
|
for (const post of feed) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
post.__source = this.sourceInfo
|
post.__source = this.sourceInfo
|
||||||
}
|
}
|
||||||
return res
|
return {success: true, cursor: res.cursor, feed}
|
||||||
} catch {
|
} catch {
|
||||||
// dont bubble custom-feed errors
|
// dont bubble custom-feed errors
|
||||||
return {success: false, headers: {}, data: {feed: []}}
|
return {success: false, feed: []}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-21
@@ -1,25 +1,22 @@
|
|||||||
import {
|
import {type Client} from '@atproto/lex-client'
|
||||||
type Agent,
|
|
||||||
type AppBskyFeedDefs,
|
|
||||||
type AppBskyFeedGetPosts,
|
|
||||||
} from '@atproto/api'
|
|
||||||
|
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
import {type FeedAPI, type FeedAPIResponse} from './types'
|
import {type FeedAPI, type FeedAPIResponse} from './types'
|
||||||
|
|
||||||
export class PostListFeedAPI implements FeedAPI {
|
export class PostListFeedAPI implements FeedAPI {
|
||||||
agent: Agent
|
client: Client
|
||||||
params: AppBskyFeedGetPosts.QueryParams
|
params: app.bsky.feed.getPosts.$Params
|
||||||
peek: AppBskyFeedDefs.FeedViewPost | null = null
|
peek: app.bsky.feed.defs.FeedViewPost | null = null
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
agent,
|
client,
|
||||||
feedParams,
|
feedParams,
|
||||||
}: {
|
}: {
|
||||||
agent: Agent
|
client: Client
|
||||||
feedParams: AppBskyFeedGetPosts.QueryParams
|
feedParams: app.bsky.feed.getPosts.$Params
|
||||||
}) {
|
}) {
|
||||||
this.agent = agent
|
this.client = client
|
||||||
if (feedParams.uris.length > 25) {
|
if (feedParams.uris.length > 25) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`Too many URIs provided - expected 25, got ${feedParams.uris.length}`,
|
`Too many URIs provided - expected 25, got ${feedParams.uris.length}`,
|
||||||
@@ -30,23 +27,18 @@ export class PostListFeedAPI implements FeedAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> {
|
async peekLatest(): Promise<app.bsky.feed.defs.FeedViewPost> {
|
||||||
if (this.peek) return this.peek
|
if (this.peek) return this.peek
|
||||||
throw new Error('Has not fetched yet')
|
throw new Error('Has not fetched yet')
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch({}: {}): Promise<FeedAPIResponse> {
|
async fetch({}: {}): Promise<FeedAPIResponse> {
|
||||||
const res = await this.agent.app.bsky.feed.getPosts({
|
const res = await this.client.call(app.bsky.feed.getPosts, {
|
||||||
...this.params,
|
...this.params,
|
||||||
})
|
})
|
||||||
if (res.success) {
|
this.peek = {post: res.posts[0]}
|
||||||
this.peek = {post: res.data.posts[0]}
|
|
||||||
return {
|
return {
|
||||||
feed: res.data.posts.map(post => ({post})),
|
feed: res.posts.map(post => ({post})),
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
feed: [],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import {type AppBskyFeedDefs} from '@atproto/api'
|
import {type app} from '#/lexicons'
|
||||||
|
|
||||||
export interface FeedAPIResponse {
|
export interface FeedAPIResponse {
|
||||||
cursor?: string
|
cursor?: string
|
||||||
feed: AppBskyFeedDefs.FeedViewPost[]
|
feed: app.bsky.feed.defs.FeedViewPost[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FeedAPI {
|
export interface FeedAPI {
|
||||||
peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost>
|
peekLatest(): Promise<app.bsky.feed.defs.FeedViewPost>
|
||||||
fetch({
|
fetch({
|
||||||
cursor,
|
cursor,
|
||||||
limit,
|
limit,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {AtUri} from '@atproto/api'
|
import {AtUri} from '@atproto/syntax'
|
||||||
|
|
||||||
import {BSKY_FEED_OWNER_DIDS} from '#/lib/constants'
|
import {BSKY_FEED_OWNER_DIDS} from '#/lib/constants'
|
||||||
import {type UsePreferencesQueryResponse} from '#/state/queries/preferences'
|
import {type UsePreferencesQueryResponse} from '#/state/queries/preferences'
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user