Skip to content

Commit

Permalink
Proxy getPopularFeedGenerators on simplified pds (#1222)
Browse files Browse the repository at this point in the history
proxy getPopularFeedGenerators on pds

Co-authored-by: dholms <[email protected]>
  • Loading branch information
devinivy and dholms authored Jun 29, 2023
1 parent e6db8e9 commit c8f1d2e
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/pds/src/api/app/bsky/proxied.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,22 @@ export default function (server: Server, ctx: AppContext) {
},
})

server.app.bsky.unspecced.getPopularFeedGenerators({
auth: ctx.accessVerifier,
handler: async ({ params, auth }) => {
const requester = auth.credentials.did
const res =
await ctx.appViewAgent.api.app.bsky.unspecced.getPopularFeedGenerators(
params,
await ctx.serviceAuthHeaders(requester),
)
return {
encoding: 'application/json',
body: res.data,
}
},
})

server.app.bsky.graph.getBlocks({
auth: ctx.accessVerifier,
handler: async ({ params, auth }) => {
Expand Down
28 changes: 28 additions & 0 deletions packages/pds/tests/proxied/__snapshots__/views.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2117,3 +2117,31 @@ Object {
],
}
`;

exports[`proxies view requests unspecced.getPopularFeedGenerators 1`] = `
Object {
"feeds": Array [
Object {
"cid": "cids(0)",
"creator": Object {
"avatar": "https://bsky.public.url/image/sig()/rs:fill:1000:1000:1:0/plain/user(1)/cids(1)@jpeg",
"did": "user(0)",
"displayName": "ali",
"handle": "alice.test",
"labels": Array [],
"viewer": Object {
"blockedBy": false,
"muted": false,
},
},
"description": "Provides all feed candidates",
"did": "did:example:feedgen",
"displayName": "All",
"indexedAt": "1970-01-01T00:00:00.000Z",
"likeCount": 0,
"uri": "record(0)",
"viewer": Object {},
},
],
}
`;
24 changes: 24 additions & 0 deletions packages/pds/tests/proxied/views.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ describe('proxies view requests', () => {
dan = sc.dids.dan
})

beforeAll(async () => {
await agent.api.app.bsky.feed.generator.create(
{ repo: alice, rkey: 'all' },
{
did: 'did:example:feedgen',
displayName: 'All',
description: 'Provides all feed candidates',
createdAt: new Date().toISOString(),
},
sc.getHeaders(alice),
)
await network.processAll()
})

afterAll(async () => {
await network.close()
})
Expand Down Expand Up @@ -274,6 +288,16 @@ describe('proxies view requests', () => {
expect([...pt1.data.feed, ...pt2.data.feed]).toEqual(res.data.feed)
})

it('unspecced.getPopularFeedGenerators', async () => {
const res = await agent.api.app.bsky.unspecced.getPopularFeedGenerators(
{},
{
headers: { ...sc.getHeaders(alice), 'x-appview-proxy': 'true' },
},
)
expect(forSnapshot(res.data)).toMatchSnapshot()
})

let feedUri: string
it('feed.getFeedGenerator', async () => {
feedUri = AtUri.make(
Expand Down

0 comments on commit c8f1d2e

Please sign in to comment.