From f2f1175335fbdde1892994be9fed44aaa091d90e Mon Sep 17 00:00:00 2001 From: Rudy Fraser Date: Wed, 11 Nov 2026 10:17:18 -0500 Subject: [PATCH] fix(moderation): send takedown appeals to the app's own moderation service The appeal on the takedown screen used the shared moderation proxy setting, which defaults to Bluesky's service. It now goes to the same service as the moderation inbox. --- src/screens/Takendown.tsx | 8 +++--- .../moderation-inbox-service.test.tsx | 11 ++++---- src/state/queries/moderation-inbox.ts | 25 ++++++------------- .../additional-moderation-authorities.ts | 10 +++++++- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/screens/Takendown.tsx b/src/screens/Takendown.tsx index e8d308bdb..d25471ff0 100644 --- a/src/screens/Takendown.tsx +++ b/src/screens/Takendown.tsx @@ -9,12 +9,10 @@ import {useMutation} from '@tanstack/react-query' import {countGraphemes} from 'unicode-segmenter/grapheme' import {useBrand} from '#/lib/community/BrandContext' -import { - MAX_REPORT_REASON_GRAPHEME_LENGTH, - MOD_PROXY_SERVICE, -} from '#/lib/constants' +import {MAX_REPORT_REASON_GRAPHEME_LENGTH} from '#/lib/constants' import {cleanError} from '#/lib/strings/errors' import {useAppviewClient, useSession, useSessionApi} from '#/state/session' +import {BLACKSKY_MOD_SERVICE} from '#/state/session/additional-moderation-authorities' import {CharProgress} from '#/view/com/composer/char-progress/CharProgress' import {Logo} from '#/view/icons/Logo' import {atoms as a, useBreakpoints, useTheme} from '#/alf' @@ -64,7 +62,7 @@ export function Takendown() { }, reason: appealText, }, - {service: MOD_PROXY_SERVICE}, + {service: BLACKSKY_MOD_SERVICE}, ) }, onSuccess: () => setReason(''), diff --git a/src/state/queries/__tests__/moderation-inbox-service.test.tsx b/src/state/queries/__tests__/moderation-inbox-service.test.tsx index a1dab8cc8..61f2a15a2 100644 --- a/src/state/queries/__tests__/moderation-inbox-service.test.tsx +++ b/src/state/queries/__tests__/moderation-inbox-service.test.tsx @@ -5,7 +5,7 @@ import {QueryClient, QueryClientProvider} from '@tanstack/react-query' import {act, renderHook, waitFor} from '@testing-library/react-native' import {useAppviewClient, useSession} from '#/state/session' -import {BLACKSKY_LABELER} from '#/state/session/additional-moderation-authorities' +import {BLACKSKY_MOD_SERVICE} from '#/state/session/additional-moderation-authorities' import {tools} from '#/lexicons' import { useModerationInboxAccountStatusQuery, @@ -16,15 +16,12 @@ jest.mock('#/state/session', () => ({ useAppviewClient: jest.fn(), useSession: jest.fn(), })) -jest.mock('#/state/session/additional-moderation-authorities', () => ({ - BLACKSKY_LABELER: 'did:plc:d2mkddsbmnrgr3domzg5qexf', -})) jest.mock('#/components/Toast', () => ({show: jest.fn()})) jest.mock('#/logger', () => ({logger: {error: jest.fn(), debug: jest.fn()}})) i18n.activate('en') -const OWN_SERVICE = `${BLACKSKY_LABELER}#atproto_labeler` +const OWN_SERVICE = BLACKSKY_MOD_SERVICE function setup() { const call = jest.fn().mockResolvedValue({}) @@ -48,6 +45,10 @@ function setup() { } describe('moderation inbox service', () => { + it('is the Blacksky moderation service', () => { + expect(OWN_SERVICE).toBe('did:plc:d2mkddsbmnrgr3domzg5qexf#atproto_labeler') + }) + it('reads the inbox from the app’s own moderation service', async () => { const {call, wrapper} = setup() diff --git a/src/state/queries/moderation-inbox.ts b/src/state/queries/moderation-inbox.ts index 162083691..e6ec77a9d 100644 --- a/src/state/queries/moderation-inbox.ts +++ b/src/state/queries/moderation-inbox.ts @@ -1,4 +1,3 @@ -import {type Service} from '@atproto/lex' import {type DidString} from '@atproto/syntax' import {useLingui} from '@lingui/react/macro' import { @@ -15,20 +14,12 @@ import {logger} from '#/logger' import {STALE} from '#/state/queries' import {createQueryKey} from '#/state/queries/util' import {useAppviewClient, useSession} from '#/state/session' -import {BLACKSKY_LABELER} from '#/state/session/additional-moderation-authorities' +import {BLACKSKY_MOD_SERVICE} from '#/state/session/additional-moderation-authorities' import * as Toast from '#/components/Toast' -import {MOD_PROXY_DID} from '#/env' import {tools} from '#/lexicons' const QUERY_KEY_ROOT = 'moderation-inbox' -/* - * The inbox belongs to this app's own moderation service. The shared - * `MOD_PROXY_SERVICE` defaults to Bluesky's, which is right for the appeals - * that use it (chat and live access) and wrong here. - */ -const INBOX_SERVICE: Service = `${MOD_PROXY_DID || BLACKSKY_LABELER}#atproto_labeler` - type ReportsFilter = NonNullable< tools.ozone.inbox.listReports.$Params['filter'] > @@ -51,7 +42,7 @@ export function useModerationInboxReportsQuery(filter: ReportsFilter) { await client.call( tools.ozone.inbox.listReports, {filter, limit: 100, cursor: pageParam}, - {service: INBOX_SERVICE}, + {service: BLACKSKY_MOD_SERVICE}, ), initialPageParam: undefined as string | undefined, getNextPageParam: lastPage => lastPage.cursor, @@ -113,7 +104,7 @@ export function useModerationInboxActionedSubjectsQuery( await client.call( tools.ozone.inbox.listActionedSubjects, {filter, limit: 30, cursor: pageParam}, - {service: INBOX_SERVICE}, + {service: BLACKSKY_MOD_SERVICE}, ), initialPageParam: undefined as string | undefined, getNextPageParam: lastPage => lastPage.cursor, @@ -133,7 +124,7 @@ export function useModerationInboxAccountStatusQuery() { await client.call( tools.ozone.inbox.getAccountStatus, {}, - {service: INBOX_SERVICE}, + {service: BLACKSKY_MOD_SERVICE}, ), staleTime: STALE.MINUTES.ONE, enabled: hasSession && !!did, @@ -262,7 +253,7 @@ export function useModerationInboxUnreadCountQuery(isEnabled = true) { await client.call( tools.ozone.inbox.getUnreadCount, {}, - {service: INBOX_SERVICE}, + {service: BLACKSKY_MOD_SERVICE}, ), staleTime: STALE.SECONDS.THIRTY, enabled: isEnabled && hasSession && !!did, @@ -285,7 +276,7 @@ export function useModerationInboxNotificationPreferencesQuery( await client.call( tools.ozone.inbox.getNotificationPreferences, {}, - {service: INBOX_SERVICE}, + {service: BLACKSKY_MOD_SERVICE}, ), staleTime: STALE.MINUTES.ONE, enabled: isEnabled && hasSession && !!did, @@ -309,7 +300,7 @@ export function useUpdateModerationInboxNotificationPreferencesMutation() { await client.call( tools.ozone.inbox.putNotificationPreferences, preferences, - {service: INBOX_SERVICE}, + {service: BLACKSKY_MOD_SERVICE}, ), onMutate: async () => { await queryClient.cancelQueries({queryKey}) @@ -353,7 +344,7 @@ export function useUpdateModerationInboxSeenMutation({ await client.call(tools.ozone.inbox.updateSeen, input, { service: moderationService ? `${moderationService}#atproto_labeler` - : INBOX_SERVICE, + : BLACKSKY_MOD_SERVICE, }), onSuccess: async () => { await queryClient.invalidateQueries({queryKey}) diff --git a/src/state/session/additional-moderation-authorities.ts b/src/state/session/additional-moderation-authorities.ts index f61690064..c6f7403e6 100644 --- a/src/state/session/additional-moderation-authorities.ts +++ b/src/state/session/additional-moderation-authorities.ts @@ -1,6 +1,7 @@ -import {Client} from '@atproto/lex' +import {Client, type Service} from '@atproto/lex' import {logger} from '#/logger' +import {MOD_PROXY_DID} from '#/env' export const BR_LABELER = 'did:plc:ekitcvx7uwnauoqy5oest3hm' // Brazil export const DE_LABELER = 'did:plc:r55ow3tocux5kafs5dq445fy' // Germany @@ -20,6 +21,13 @@ export const EU_LABELER = 'did:plc:z57lz5dhgz2dkjogoysm3vut' export const BLACKSKY_LABELER = 'did:plc:d2mkddsbmnrgr3domzg5qexf' +/** + * This app's own moderation service: where its moderation inbox is read and + * where appeals against its own takedowns go. The shared `MOD_PROXY_SERVICE` + * defaults to Bluesky's, which stays right for chat and live access appeals. + */ +export const BLACKSKY_MOD_SERVICE: Service = `${MOD_PROXY_DID || BLACKSKY_LABELER}#atproto_labeler` + const MODERATION_AUTHORITIES: { [countryCode: string]: string[] } = { -- knotmirror 0.0.1