Skip to content

Commit

Permalink
Allow using a handle as "actor" param in app.bsky.graph.getLists (#2853)
Browse files Browse the repository at this point in the history
* Allow using a handle as "actor" param in app.bsky.graph.getLists

* tests
  • Loading branch information
matthieusieben authored Oct 4, 2024
1 parent 4e09849 commit 72549f4
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/eleven-walls-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/bsky": patch
---

Allow using a handle as "actor" param in app.bsky.graph.getLists
7 changes: 6 additions & 1 deletion packages/bsky/src/api/app/bsky/graph/getLists.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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,
})
Expand Down
33 changes: 33 additions & 0 deletions packages/bsky/tests/views/__snapshots__/lists.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
},
]
`;
8 changes: 8 additions & 0 deletions packages/bsky/tests/views/lists.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down

0 comments on commit 72549f4

Please sign in to comment.