Skip to content

Commit

Permalink
Resolve record instead of feed view for getFeed (bluesky-social#3034)
Browse files Browse the repository at this point in the history
* resolve record instead of feed view for getFeed

* changeset
  • Loading branch information
dholms authored Nov 18, 2024
1 parent a4b528e commit 90399c8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-schools-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/pds": patch
---

use getRecord in getFeed rather than resolving full view
23 changes: 15 additions & 8 deletions packages/pds/src/api/app/bsky/feed/getFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Server } from '../../../../lexicon'
import AppContext from '../../../../context'
import { pipethrough } from '../../../../pipethrough'
import { ids } from '../../../../lexicon/lexicons'
import { AtUri } from '@atproto/syntax'
import { InvalidRequestError } from '@atproto/oauth-provider'

export default function (server: Server, ctx: AppContext) {
const { appViewAgent } = ctx
Expand All @@ -12,18 +14,23 @@ export default function (server: Server, ctx: AppContext) {
handler: async ({ params, auth, req }) => {
const requester = auth.credentials.did

const { data: feed } =
await appViewAgent.api.app.bsky.feed.getFeedGenerator(
{ feed: params.feed },
await ctx.appviewAuthHeaders(
requester,
ids.AppBskyFeedGetFeedGenerator,
),
const feedUrl = new AtUri(params.feed)
const { data } = await appViewAgent.com.atproto.repo.getRecord({
repo: feedUrl.hostname,
collection: feedUrl.collection,
rkey: feedUrl.rkey,
})
const feedDid = data.value['did']
if (typeof feedDid !== 'string') {
throw new InvalidRequestError(
'could not resolve feed did',
'UnknownFeed',
)
}

return pipethrough(ctx, req, {
iss: requester,
aud: feed.view.did,
aud: feedDid,
lxm: ids.AppBskyFeedGetFeedSkeleton,
})
},
Expand Down

0 comments on commit 90399c8

Please sign in to comment.