Skip to content

Commit ac0c4ef

Browse files
authored
ensure headers are set when chat reporting (#8985)
1 parent 9172567 commit ac0c4ef

File tree

4 files changed

+35
-20
lines changed

4 files changed

+35
-20
lines changed

src/components/ageAssurance/AgeAssuranceAppealDialog.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React from 'react'
22
import {View} from 'react-native'
3-
import {BSKY_LABELER_DID, ComAtprotoModerationDefs} from '@atproto/api'
3+
import {ComAtprotoModerationDefs} from '@atproto/api'
44
import {msg, Trans} from '@lingui/macro'
55
import {useLingui} from '@lingui/react'
66
import {useMutation} from '@tanstack/react-query'
77

8+
import {BLUESKY_MOD_SERVICE_HEADERS} from '#/lib/constants'
89
import {logger} from '#/state/ageAssurance/util'
910
import {useAgent, useSession} from '#/state/session'
1011
import * as Toast from '#/view/com/util/Toast'
@@ -58,9 +59,7 @@ function Inner({control}: {control: Dialog.DialogControlProps}) {
5859
},
5960
{
6061
encoding: 'application/json',
61-
headers: {
62-
'atproto-proxy': `${BSKY_LABELER_DID}#atproto_labeler`,
63-
},
62+
headers: BLUESKY_MOD_SERVICE_HEADERS,
6463
},
6564
)
6665
},

src/components/dms/ReportDialog.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
import React, {memo, useMemo, useState} from 'react'
1+
import {memo, useMemo, useState} from 'react'
22
import {View} from 'react-native'
33
import {
4-
$Typed,
5-
AppBskyActorDefs,
6-
ChatBskyConvoDefs,
7-
ComAtprotoModerationCreateReport,
4+
type $Typed,
5+
type AppBskyActorDefs,
6+
type ChatBskyConvoDefs,
7+
type ComAtprotoModerationCreateReport,
88
RichText as RichTextAPI,
99
} from '@atproto/api'
1010
import {msg, Trans} from '@lingui/macro'
1111
import {useLingui} from '@lingui/react'
1212
import {StackActions, useNavigation} from '@react-navigation/native'
1313
import {useMutation} from '@tanstack/react-query'
14+
import type React from 'react'
1415

15-
import {ReportOption} from '#/lib/moderation/useReportOptions'
16-
import {NavigationProp} from '#/lib/routes/types'
16+
import {BLUESKY_MOD_SERVICE_HEADERS} from '#/lib/constants'
17+
import {type ReportOption} from '#/lib/moderation/useReportOptions'
18+
import {type NavigationProp} from '#/lib/routes/types'
1719
import {isNative} from '#/platform/detection'
1820
import {useProfileShadow} from '#/state/cache/profile-shadow'
1921
import {useLeaveConvo} from '#/state/queries/messages/leave-conversation'
@@ -168,7 +170,10 @@ function SubmitStep({
168170
reason: details,
169171
} satisfies ComAtprotoModerationCreateReport.InputSchema
170172

171-
await agent.createModerationReport(report)
173+
await agent.createModerationReport(report, {
174+
encoding: 'application/json',
175+
headers: BLUESKY_MOD_SERVICE_HEADERS,
176+
})
172177
}
173178
},
174179
onSuccess: onComplete,

src/lib/constants.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {type Insets, Platform} from 'react-native'
2-
import {type AppBskyActorDefs} from '@atproto/api'
2+
import {type AppBskyActorDefs, BSKY_LABELER_DID} from '@atproto/api'
33

44
import {type ProxyHeaderValue} from '#/state/session/agent'
55
import {BLUESKY_PROXY_DID, CHAT_PROXY_DID} from '#/env'
@@ -228,6 +228,10 @@ export const DM_SERVICE_HEADERS = {
228228
'atproto-proxy': `${CHAT_PROXY_DID}#bsky_chat`,
229229
}
230230

231+
export const BLUESKY_MOD_SERVICE_HEADERS = {
232+
'atproto-proxy': `${BSKY_LABELER_DID}#atproto_labeler`,
233+
}
234+
231235
export const webLinks = {
232236
tos: `https://bsky.social/about/support/tos`,
233237
privacy: `https://bsky.social/about/support/privacy-policy`,

src/screens/Messages/components/ChatDisabled.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {msg, Trans} from '@lingui/macro'
55
import {useLingui} from '@lingui/react'
66
import {useMutation} from '@tanstack/react-query'
77

8+
import {BLUESKY_MOD_SERVICE_HEADERS} from '#/lib/constants'
89
import {logger} from '#/logger'
910
import {useAgent, useSession} from '#/state/session'
1011
import * as Toast from '#/view/com/util/Toast'
@@ -73,14 +74,20 @@ function DialogInner() {
7374
mutationFn: async () => {
7475
if (!currentAccount)
7576
throw new Error('No current account, should be unreachable')
76-
await agent.createModerationReport({
77-
reasonType: ComAtprotoModerationDefs.REASONAPPEAL,
78-
subject: {
79-
$type: 'com.atproto.admin.defs#repoRef',
80-
did: currentAccount.did,
77+
await agent.createModerationReport(
78+
{
79+
reasonType: ComAtprotoModerationDefs.REASONAPPEAL,
80+
subject: {
81+
$type: 'com.atproto.admin.defs#repoRef',
82+
did: currentAccount.did,
83+
},
84+
reason: details,
8185
},
82-
reason: details,
83-
})
86+
{
87+
encoding: 'application/json',
88+
headers: BLUESKY_MOD_SERVICE_HEADERS,
89+
},
90+
)
8491
},
8592
onError: err => {
8693
logger.error('Failed to submit chat appeal', {message: err})

0 commit comments

Comments
 (0)