Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using a handle as "actor" param in app.bsky.graph.getLists #2853

Merged
merged 2 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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