Remove .withProxy() calls (#4929)
parent
1fce7a793d
commit
7e11b862e9
|
@ -6,7 +6,6 @@ import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {getLabelingServiceTitle} from '#/lib/moderation'
|
import {getLabelingServiceTitle} from '#/lib/moderation'
|
||||||
import {ReportOption} from '#/lib/moderation/useReportOptions'
|
import {ReportOption} from '#/lib/moderation/useReportOptions'
|
||||||
import {useGate} from '#/lib/statsig/statsig'
|
|
||||||
import {useAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
import {CharProgress} from '#/view/com/composer/char-progress/CharProgress'
|
import {CharProgress} from '#/view/com/composer/char-progress/CharProgress'
|
||||||
import * as Toast from '#/view/com/util/Toast'
|
import * as Toast from '#/view/com/util/Toast'
|
||||||
|
@ -37,7 +36,6 @@ export function SubmitView({
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const agent = useAgent()
|
const agent = useAgent()
|
||||||
const gate = useGate()
|
|
||||||
const [details, setDetails] = React.useState<string>('')
|
const [details, setDetails] = React.useState<string>('')
|
||||||
const [submitting, setSubmitting] = React.useState<boolean>(false)
|
const [submitting, setSubmitting] = React.useState<boolean>(false)
|
||||||
const [selectedServices, setSelectedServices] = React.useState<string[]>([
|
const [selectedServices, setSelectedServices] = React.useState<string[]>([
|
||||||
|
@ -63,27 +61,17 @@ export function SubmitView({
|
||||||
}
|
}
|
||||||
const results = await Promise.all(
|
const results = await Promise.all(
|
||||||
selectedServices.map(did => {
|
selectedServices.map(did => {
|
||||||
if (gate('session_withproxy_fix')) {
|
return agent
|
||||||
return agent
|
.createModerationReport(report, {
|
||||||
.createModerationReport(report, {
|
encoding: 'application/json',
|
||||||
encoding: 'application/json',
|
headers: {
|
||||||
headers: {
|
'atproto-proxy': `${did}#atproto_labeler`,
|
||||||
'atproto-proxy': `${did}#atproto_labeler`,
|
},
|
||||||
},
|
})
|
||||||
})
|
.then(
|
||||||
.then(
|
_ => true,
|
||||||
_ => true,
|
_ => false,
|
||||||
_ => false,
|
)
|
||||||
)
|
|
||||||
} else {
|
|
||||||
return agent
|
|
||||||
.withProxy('atproto_labeler', did)
|
|
||||||
.createModerationReport(report)
|
|
||||||
.then(
|
|
||||||
_ => true,
|
|
||||||
_ => false,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -108,7 +96,6 @@ export function SubmitView({
|
||||||
onSubmitComplete,
|
onSubmitComplete,
|
||||||
setError,
|
setError,
|
||||||
agent,
|
agent,
|
||||||
gate,
|
|
||||||
])
|
])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -7,7 +7,6 @@ import {useMutation} from '@tanstack/react-query'
|
||||||
|
|
||||||
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 {useGate} from '#/lib/statsig/statsig'
|
|
||||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {useAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
|
@ -204,7 +203,6 @@ function AppealForm({
|
||||||
const [details, setDetails] = React.useState('')
|
const [details, setDetails] = React.useState('')
|
||||||
const isAccountReport = 'did' in subject
|
const isAccountReport = 'did' in subject
|
||||||
const agent = useAgent()
|
const agent = useAgent()
|
||||||
const gate = useGate()
|
|
||||||
const sourceName = labeler
|
const sourceName = labeler
|
||||||
? sanitizeHandle(labeler.creator.handle, '@')
|
? sanitizeHandle(labeler.creator.handle, '@')
|
||||||
: label.src
|
: label.src
|
||||||
|
@ -214,35 +212,22 @@ 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'
|
||||||
if (gate('session_withproxy_fix')) {
|
await agent.createModerationReport(
|
||||||
await agent.createModerationReport(
|
{
|
||||||
{
|
reasonType: ComAtprotoModerationDefs.REASONAPPEAL,
|
||||||
reasonType: ComAtprotoModerationDefs.REASONAPPEAL,
|
subject: {
|
||||||
subject: {
|
$type,
|
||||||
$type,
|
...subject,
|
||||||
...subject,
|
|
||||||
},
|
|
||||||
reason: details,
|
|
||||||
},
|
},
|
||||||
{
|
reason: details,
|
||||||
encoding: 'application/json',
|
},
|
||||||
headers: {
|
{
|
||||||
'atproto-proxy': `${label.src}#atproto_labeler`,
|
encoding: 'application/json',
|
||||||
},
|
headers: {
|
||||||
|
'atproto-proxy': `${label.src}#atproto_labeler`,
|
||||||
},
|
},
|
||||||
)
|
},
|
||||||
} else {
|
)
|
||||||
await agent
|
|
||||||
.withProxy('atproto_labeler', label.src)
|
|
||||||
.createModerationReport({
|
|
||||||
reasonType: ComAtprotoModerationDefs.REASONAPPEAL,
|
|
||||||
subject: {
|
|
||||||
$type,
|
|
||||||
...subject,
|
|
||||||
},
|
|
||||||
reason: details,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onError: err => {
|
onError: err => {
|
||||||
logger.error('Failed to submit label appeal', {message: err})
|
logger.error('Failed to submit label appeal', {message: err})
|
||||||
|
|
|
@ -3,7 +3,6 @@ export type Gate =
|
||||||
| 'debug_show_feedcontext'
|
| 'debug_show_feedcontext'
|
||||||
| 'new_user_guided_tour'
|
| 'new_user_guided_tour'
|
||||||
| 'onboarding_minimum_interests'
|
| 'onboarding_minimum_interests'
|
||||||
| 'session_withproxy_fix'
|
|
||||||
| 'show_follow_back_label_v2'
|
| 'show_follow_back_label_v2'
|
||||||
| 'suggested_feeds_interstitial'
|
| 'suggested_feeds_interstitial'
|
||||||
| 'video_debug'
|
| 'video_debug'
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {AppState, AppStateStatus} from 'react-native'
|
import {AppState, AppStateStatus} from 'react-native'
|
||||||
import {AppBskyFeedDefs, BskyAgent} from '@atproto/api'
|
import {AppBskyFeedDefs} from '@atproto/api'
|
||||||
import throttle from 'lodash.throttle'
|
import throttle from 'lodash.throttle'
|
||||||
|
|
||||||
import {PROD_DEFAULT_FEED} from '#/lib/constants'
|
import {PROD_DEFAULT_FEED} from '#/lib/constants'
|
||||||
import {logEvent} from '#/lib/statsig/statsig'
|
import {logEvent} from '#/lib/statsig/statsig'
|
||||||
import {useGate} from '#/lib/statsig/statsig'
|
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {FeedDescriptor, FeedPostSliceItem} from '#/state/queries/post-feed'
|
import {FeedDescriptor, FeedPostSliceItem} from '#/state/queries/post-feed'
|
||||||
import {getFeedPostSlice} from '#/view/com/posts/Feed'
|
import {getFeedPostSlice} from '#/view/com/posts/Feed'
|
||||||
|
@ -25,7 +24,6 @@ const stateContext = React.createContext<StateContext>({
|
||||||
|
|
||||||
export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) {
|
export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) {
|
||||||
const agent = useAgent()
|
const agent = useAgent()
|
||||||
const gate = useGate()
|
|
||||||
const enabled = isDiscoverFeed(feed) && hasSession
|
const enabled = isDiscoverFeed(feed) && hasSession
|
||||||
const queue = React.useRef<Set<string>>(new Set())
|
const queue = React.useRef<Set<string>>(new Set())
|
||||||
const history = React.useRef<
|
const history = React.useRef<
|
||||||
|
@ -49,34 +47,20 @@ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) {
|
||||||
queue.current.clear()
|
queue.current.clear()
|
||||||
|
|
||||||
// Send to the feed
|
// Send to the feed
|
||||||
if (gate('session_withproxy_fix')) {
|
agent.app.bsky.feed
|
||||||
agent.app.bsky.feed
|
.sendInteractions(
|
||||||
.sendInteractions(
|
{interactions},
|
||||||
{interactions},
|
{
|
||||||
{
|
encoding: 'application/json',
|
||||||
encoding: 'application/json',
|
headers: {
|
||||||
headers: {
|
// TODO when we start sending to other feeds, we need to grab their DID -prf
|
||||||
// TODO when we start sending to other feeds, we need to grab their DID -prf
|
'atproto-proxy': 'did:web:discover.bsky.app#bsky_fg',
|
||||||
'atproto-proxy': 'did:web:discover.bsky.app#bsky_fg',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
)
|
},
|
||||||
.catch((e: any) => {
|
)
|
||||||
logger.warn('Failed to send feed interactions', {error: e})
|
.catch((e: any) => {
|
||||||
})
|
logger.warn('Failed to send feed interactions', {error: e})
|
||||||
} else {
|
})
|
||||||
const proxyAgent = agent.withProxy(
|
|
||||||
// @ts-ignore TODO need to update withProxy() to support this key -prf
|
|
||||||
'bsky_fg',
|
|
||||||
// TODO when we start sending to other feeds, we need to grab their DID -prf
|
|
||||||
'did:web:discover.bsky.app',
|
|
||||||
) as BskyAgent
|
|
||||||
proxyAgent.app.bsky.feed
|
|
||||||
.sendInteractions({interactions})
|
|
||||||
.catch((e: any) => {
|
|
||||||
logger.warn('Failed to send feed interactions', {error: e})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send to Statsig
|
// Send to Statsig
|
||||||
if (aggregatedStats.current === null) {
|
if (aggregatedStats.current === null) {
|
||||||
|
@ -84,7 +68,7 @@ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) {
|
||||||
}
|
}
|
||||||
sendOrAggregateInteractionsForStats(aggregatedStats.current, interactions)
|
sendOrAggregateInteractionsForStats(aggregatedStats.current, interactions)
|
||||||
throttledFlushAggregatedStats()
|
throttledFlushAggregatedStats()
|
||||||
}, [agent, gate, throttledFlushAggregatedStats])
|
}, [agent, throttledFlushAggregatedStats])
|
||||||
|
|
||||||
const sendToFeed = React.useMemo(
|
const sendToFeed = React.useMemo(
|
||||||
() =>
|
() =>
|
||||||
|
|
Loading…
Reference in New Issue