-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/appview-v2-popular-feeds-init' i…
…nto appview-v2-testing
- Loading branch information
Showing
1 changed file
with
25 additions
and
3 deletions.
There are no files selected for viewing
28 changes: 25 additions & 3 deletions
28
packages/bsky/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,35 @@ | ||
import { mapDefined } from '@atproto/common' | ||
import { Server } from '../../../../lexicon' | ||
import AppContext from '../../../../context' | ||
import { parseString } from '../../../../hydration/util' | ||
|
||
// THIS IS A TEMPORARY UNSPECCED ROUTE | ||
// @TODO currently mirrors getSuggestedFeeds and ignores the "query" param. | ||
// In the future may take into consideration popularity via likes w/ its own dataplane endpoint. | ||
export default function (server: Server, ctx: AppContext) { | ||
server.app.bsky.unspecced.getPopularFeedGenerators({ | ||
auth: ctx.authVerifier.standardOptional, | ||
handler: async (_reqCtx) => { | ||
// @TODO for appview v2 | ||
throw new Error('unimplemented') | ||
handler: async ({ auth, params }) => { | ||
const viewer = auth.credentials.iss | ||
|
||
const suggestedRes = await ctx.dataplane.getSuggestedFeeds({ | ||
actorDid: viewer ?? undefined, | ||
limit: params.limit, | ||
cursor: params.cursor, | ||
}) | ||
const uris = suggestedRes.uris | ||
const hydration = await ctx.hydrator.hydrateFeedGens(uris, viewer) | ||
const feedViews = mapDefined(uris, (uri) => | ||
ctx.views.feedGenerator(uri, hydration), | ||
) | ||
|
||
return { | ||
encoding: 'application/json', | ||
body: { | ||
feeds: feedViews, | ||
cursor: parseString(suggestedRes.cursor), | ||
}, | ||
} | ||
}, | ||
}) | ||
} |