Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/appview-v2-popular-feeds-init' i…
Browse files Browse the repository at this point in the history
…nto appview-v2-testing
  • Loading branch information
devinivy committed Jan 23, 2024
2 parents 8c02e21 + 8b81a3e commit dad6ed6
Showing 1 changed file with 25 additions and 3 deletions.
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),
},
}
},
})
}

0 comments on commit dad6ed6

Please sign in to comment.