From 3d3ab32ae19be3e3419faa1f82f9dd2b1356ddf3 Mon Sep 17 00:00:00 2001 From: Matthieu Sieben Date: Fri, 27 Sep 2024 15:05:36 +0200 Subject: [PATCH 1/2] Allow using a handle as "actor" param in app.bsky.graph.getLists --- .changeset/eleven-walls-cover.md | 5 +++++ packages/bsky/src/api/app/bsky/graph/getLists.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/eleven-walls-cover.md diff --git a/.changeset/eleven-walls-cover.md b/.changeset/eleven-walls-cover.md new file mode 100644 index 00000000000..249dc417699 --- /dev/null +++ b/.changeset/eleven-walls-cover.md @@ -0,0 +1,5 @@ +--- +"@atproto/bsky": patch +--- + +Allow using a handle as "actor" param in app.bsky.graph.getLists diff --git a/packages/bsky/src/api/app/bsky/graph/getLists.ts b/packages/bsky/src/api/app/bsky/graph/getLists.ts index 081c64fbc19..31d241710c2 100644 --- a/packages/bsky/src/api/app/bsky/graph/getLists.ts +++ b/packages/bsky/src/api/app/bsky/graph/getLists.ts @@ -1,4 +1,5 @@ import { mapDefined } from '@atproto/common' +import { InvalidRequestError } from '@atproto/xrpc-server' import { Server } from '../../../../lexicon' import { QueryParams } from '../../../../lexicon/types/app/bsky/graph/getLists' import { REFERENCELIST } from '../../../../lexicon/types/app/bsky/graph/defs' @@ -49,8 +50,12 @@ const skeleton = async ( if (clearlyBadCursor(params.cursor)) { return { listUris: [] } } + + const [did] = await ctx.hydrator.actor.getDids([params.actor]) + if (!did) throw new InvalidRequestError('Profile not found') + const { listUris, cursor } = await ctx.hydrator.dataplane.getActorLists({ - actorDid: params.actor, + actorDid: did, cursor: params.cursor, limit: params.limit, }) From dc7b42020009e6ed5f7d8d7ce433edc398510fe2 Mon Sep 17 00:00:00 2001 From: Matthieu Sieben Date: Thu, 3 Oct 2024 14:05:08 +0200 Subject: [PATCH 2/2] tests --- .../views/__snapshots__/lists.test.ts.snap | 33 +++++++++++++++++++ packages/bsky/tests/views/lists.test.ts | 8 +++++ 2 files changed, 41 insertions(+) diff --git a/packages/bsky/tests/views/__snapshots__/lists.test.ts.snap b/packages/bsky/tests/views/__snapshots__/lists.test.ts.snap index da10fb14752..82842d664ab 100644 --- a/packages/bsky/tests/views/__snapshots__/lists.test.ts.snap +++ b/packages/bsky/tests/views/__snapshots__/lists.test.ts.snap @@ -343,3 +343,36 @@ Array [ }, ] `; + +exports[`bsky actor likes feed views supports using a handle as getList actor param 1`] = ` +Array [ + Object { + "cid": "cids(0)", + "creator": Object { + "did": "user(0)", + "handle": "eve.test", + "labels": Array [], + }, + "indexedAt": "1970-01-01T00:00:00.000Z", + "labels": Array [], + "listItemCount": 0, + "name": "cool curate list", + "purpose": "app.bsky.graph.defs#curatelist", + "uri": "record(0)", + }, + Object { + "cid": "cids(1)", + "creator": Object { + "did": "user(0)", + "handle": "eve.test", + "labels": Array [], + }, + "indexedAt": "1970-01-01T00:00:00.000Z", + "labels": Array [], + "listItemCount": 3, + "name": "blah curate list!", + "purpose": "app.bsky.graph.defs#curatelist", + "uri": "record(1)", + }, +] +`; diff --git a/packages/bsky/tests/views/lists.test.ts b/packages/bsky/tests/views/lists.test.ts index e725050b4a5..15266746d2b 100644 --- a/packages/bsky/tests/views/lists.test.ts +++ b/packages/bsky/tests/views/lists.test.ts @@ -82,6 +82,14 @@ describe('bsky actor likes feed views', () => { expect(forSnapshot(view.data.lists)).toMatchSnapshot() }) + it('supports using a handle as getList actor param', async () => { + const view = await agent.app.bsky.graph.getLists({ + actor: 'eve.test', + }) + expect(view.data.lists.length).toBe(2) + expect(forSnapshot(view.data.lists)).toMatchSnapshot() + }) + it('does not include users with creator block relationship in reference lists for non-creator, in-list viewers', async () => { const curView = await agent.api.app.bsky.graph.getList( {