An ATproto social media client -- with an independent Appview.

ensure headers are set when chat reporting (#8985)

authored by samuel.fm and committed by

GitHub ac0c4ef2 91725671

+35 -20
+3 -4
src/components/ageAssurance/AgeAssuranceAppealDialog.tsx
··· 1 1 import React from 'react' 2 2 import {View} from 'react-native' 3 - import {BSKY_LABELER_DID, ComAtprotoModerationDefs} from '@atproto/api' 3 + import {ComAtprotoModerationDefs} from '@atproto/api' 4 4 import {msg, Trans} from '@lingui/macro' 5 5 import {useLingui} from '@lingui/react' 6 6 import {useMutation} from '@tanstack/react-query' 7 7 8 + import {BLUESKY_MOD_SERVICE_HEADERS} from '#/lib/constants' 8 9 import {logger} from '#/state/ageAssurance/util' 9 10 import {useAgent, useSession} from '#/state/session' 10 11 import * as Toast from '#/view/com/util/Toast' ··· 58 59 }, 59 60 { 60 61 encoding: 'application/json', 61 - headers: { 62 - 'atproto-proxy': `${BSKY_LABELER_DID}#atproto_labeler`, 63 - }, 62 + headers: BLUESKY_MOD_SERVICE_HEADERS, 64 63 }, 65 64 ) 66 65 },
+13 -8
src/components/dms/ReportDialog.tsx
··· 1 - import React, {memo, useMemo, useState} from 'react' 1 + import {memo, useMemo, useState} from 'react' 2 2 import {View} from 'react-native' 3 3 import { 4 - $Typed, 5 - AppBskyActorDefs, 6 - ChatBskyConvoDefs, 7 - ComAtprotoModerationCreateReport, 4 + type $Typed, 5 + type AppBskyActorDefs, 6 + type ChatBskyConvoDefs, 7 + type ComAtprotoModerationCreateReport, 8 8 RichText as RichTextAPI, 9 9 } from '@atproto/api' 10 10 import {msg, Trans} from '@lingui/macro' 11 11 import {useLingui} from '@lingui/react' 12 12 import {StackActions, useNavigation} from '@react-navigation/native' 13 13 import {useMutation} from '@tanstack/react-query' 14 + import type React from 'react' 14 15 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' 17 19 import {isNative} from '#/platform/detection' 18 20 import {useProfileShadow} from '#/state/cache/profile-shadow' 19 21 import {useLeaveConvo} from '#/state/queries/messages/leave-conversation' ··· 168 170 reason: details, 169 171 } satisfies ComAtprotoModerationCreateReport.InputSchema 170 172 171 - await agent.createModerationReport(report) 173 + await agent.createModerationReport(report, { 174 + encoding: 'application/json', 175 + headers: BLUESKY_MOD_SERVICE_HEADERS, 176 + }) 172 177 } 173 178 }, 174 179 onSuccess: onComplete,
+5 -1
src/lib/constants.ts
··· 1 1 import {type Insets, Platform} from 'react-native' 2 - import {type AppBskyActorDefs} from '@atproto/api' 2 + import {type AppBskyActorDefs, BSKY_LABELER_DID} from '@atproto/api' 3 3 4 4 import {type ProxyHeaderValue} from '#/state/session/agent' 5 5 import {BLUESKY_PROXY_DID, CHAT_PROXY_DID} from '#/env' ··· 226 226 227 227 export const DM_SERVICE_HEADERS = { 228 228 'atproto-proxy': `${CHAT_PROXY_DID}#bsky_chat`, 229 + } 230 + 231 + export const BLUESKY_MOD_SERVICE_HEADERS = { 232 + 'atproto-proxy': `${BSKY_LABELER_DID}#atproto_labeler`, 229 233 } 230 234 231 235 export const webLinks = {
+14 -7
src/screens/Messages/components/ChatDisabled.tsx
··· 5 5 import {useLingui} from '@lingui/react' 6 6 import {useMutation} from '@tanstack/react-query' 7 7 8 + import {BLUESKY_MOD_SERVICE_HEADERS} from '#/lib/constants' 8 9 import {logger} from '#/logger' 9 10 import {useAgent, useSession} from '#/state/session' 10 11 import * as Toast from '#/view/com/util/Toast' ··· 73 74 mutationFn: async () => { 74 75 if (!currentAccount) 75 76 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, 81 85 }, 82 - reason: details, 83 - }) 86 + { 87 + encoding: 'application/json', 88 + headers: BLUESKY_MOD_SERVICE_HEADERS, 89 + }, 90 + ) 84 91 }, 85 92 onError: err => { 86 93 logger.error('Failed to submit chat appeal', {message: err})