diff --git a/packages/bsky/src/api/app/bsky/actor/getProfile.ts b/packages/bsky/src/api/app/bsky/actor/getProfile.ts index f9bfc18468c..046312114b6 100644 --- a/packages/bsky/src/api/app/bsky/actor/getProfile.ts +++ b/packages/bsky/src/api/app/bsky/actor/getProfile.ts @@ -60,7 +60,9 @@ const hydration = async (input: { const { ctx, params, skeleton } = input return ctx.hydrator.hydrateProfilesDetailed( [skeleton.did], - params.hydrateCtx.copy({ includeTakedowns: true }), + params.hydrateCtx.copy({ + includeActorTakedowns: true, + }), ) } diff --git a/packages/bsky/src/auth-verifier.ts b/packages/bsky/src/auth-verifier.ts index 152e154e2c9..d1bc06cc8d0 100644 --- a/packages/bsky/src/auth-verifier.ts +++ b/packages/bsky/src/auth-verifier.ts @@ -18,14 +18,7 @@ import { unpackIdentityKeys, } from './data-plane' import { GetIdentityByDidResponse } from './proto/bsky_pb' -import { - extractMultikey, - extractPrefixedBytes, - hasPrefix, - parseDidKey, - SECP256K1_DID_PREFIX, - SECP256K1_JWT_ALG, -} from '@atproto/crypto' +import { parseDidKey, SECP256K1_JWT_ALG } from '@atproto/crypto' type ReqCtx = { req: express.Request diff --git a/packages/bsky/src/hydration/hydrator.ts b/packages/bsky/src/hydration/hydrator.ts index c19adb3b3d8..3afa6b7096c 100644 --- a/packages/bsky/src/hydration/hydrator.ts +++ b/packages/bsky/src/hydration/hydrator.ts @@ -65,6 +65,7 @@ export class HydrateCtx { labelers = this.vals.labelers viewer = this.vals.viewer !== null ? serviceRefToDid(this.vals.viewer) : null includeTakedowns = this.vals.includeTakedowns + includeActorTakedowns = this.vals.includeActorTakedowns include3pBlocks = this.vals.include3pBlocks constructor(private vals: HydrateCtxVals) {} copy>(vals?: V): HydrateCtx & V { @@ -76,6 +77,7 @@ export type HydrateCtxVals = { labelers: ParsedLabelers viewer: string | null includeTakedowns?: boolean + includeActorTakedowns?: boolean include3pBlocks?: boolean } @@ -179,12 +181,13 @@ export class Hydrator { dids: string[], ctx: HydrateCtx, ): Promise { + const includeTakedowns = ctx.includeTakedowns || ctx.includeActorTakedowns const [actors, labels, profileViewersState] = await Promise.all([ - this.actor.getActors(dids, ctx.includeTakedowns), + this.actor.getActors(dids, includeTakedowns), this.label.getLabelsForSubjects(labelSubjectsForDid(dids), ctx.labelers), this.hydrateProfileViewers(dids, ctx), ]) - if (!ctx.includeTakedowns) { + if (!includeTakedowns) { actionTakedownLabels(dids, actors, labels) } return mergeStates(profileViewersState ?? {}, { diff --git a/packages/bsky/tests/views/labels-takedown.test.ts b/packages/bsky/tests/views/labels-takedown.test.ts index 270260dd62e..5e2e58581bb 100644 --- a/packages/bsky/tests/views/labels-takedown.test.ts +++ b/packages/bsky/tests/views/labels-takedown.test.ts @@ -5,6 +5,7 @@ import { ids } from '../../src/lexicon/lexicons' describe('bsky takedown labels', () => { let network: TestNetwork let agent: AtpAgent + let pdsAgent: AtpAgent let sc: SeedClient let takendownSubjects: string[] @@ -20,10 +21,21 @@ describe('bsky takedown labels', () => { dbPostgresSchema: 'bsky_views_takedown_labels', }) agent = network.bsky.getClient() + pdsAgent = network.pds.getClient() sc = network.getSeedClient() await basicSeed(sc) aliceListRef = await sc.createList(sc.dids.alice, 'alice list', 'mod') + // carol blocks dan via alice's (takendown) list + await sc.addToList(sc.dids.alice, sc.dids.dan, aliceListRef) + await pdsAgent.app.bsky.graph.listblock.create( + { repo: sc.dids.carol }, + { + subject: aliceListRef.uriStr, + createdAt: new Date().toISOString(), + }, + sc.getHeaders(sc.dids.carol), + ) carolListRef = await sc.createList(sc.dids.carol, 'carol list', 'mod') aliceGenRef = await sc.createFeedGen( sc.dids.alice, @@ -159,6 +171,25 @@ describe('bsky takedown labels', () => { await expect(attempt2).rejects.toThrow('List not found') }) + it('halts application of mod lists', async () => { + const { data: profile } = await agent.app.bsky.actor.getProfile( + { + actor: sc.dids.dan, // blocked via alice's takendown list + }, + { + headers: await network.serviceHeaders( + sc.dids.carol, + ids.AppBskyActorGetProfile, + ), + }, + ) + expect(profile.did).toBe(sc.dids.dan) + expect(profile.viewer).not.toBeUndefined() + expect(profile.viewer?.blockedBy).toBe(false) + expect(profile.viewer?.blocking).toBeUndefined() + expect(profile.viewer?.blockingByList).toBeUndefined() + }) + it('takesdown feed generators', async () => { const res = await agent.api.app.bsky.feed.getFeedGenerators({ feeds: [aliceGenRef.uriStr, bobGenRef.uriStr, carolGenRef.uriStr],