From 90399c85955301babc689c293bd3e7e1a94505a3 Mon Sep 17 00:00:00 2001 From: Daniel Holmgren Date: Mon, 18 Nov 2024 15:39:32 -0600 Subject: [PATCH] Resolve record instead of feed view for getFeed (#3034) * resolve record instead of feed view for getFeed * changeset --- .changeset/mighty-schools-yawn.md | 5 ++++ packages/pds/src/api/app/bsky/feed/getFeed.ts | 23 ++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 .changeset/mighty-schools-yawn.md diff --git a/.changeset/mighty-schools-yawn.md b/.changeset/mighty-schools-yawn.md new file mode 100644 index 00000000000..7be55d62369 --- /dev/null +++ b/.changeset/mighty-schools-yawn.md @@ -0,0 +1,5 @@ +--- +"@atproto/pds": patch +--- + +use getRecord in getFeed rather than resolving full view diff --git a/packages/pds/src/api/app/bsky/feed/getFeed.ts b/packages/pds/src/api/app/bsky/feed/getFeed.ts index 0e25f4484d0..156fac7257d 100644 --- a/packages/pds/src/api/app/bsky/feed/getFeed.ts +++ b/packages/pds/src/api/app/bsky/feed/getFeed.ts @@ -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 @@ -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, }) },