Skip to content

Commit

Permalink
correctly proxy feed.searchPosts
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Nov 15, 2023
1 parent 619c7f0 commit 5630a12
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions packages/pds/src/api/app/bsky/feed/searchPosts.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
import { Server } from '../../../../lexicon'
import AppContext from '../../../../context'
import {
authPassthru,
proxy,
proxyAppView,
resultPassthru,
} from '../../../proxy'

export default function (server: Server, ctx: AppContext) {
server.app.bsky.feed.searchPosts({
auth: ctx.authVerifier.access,
handler: async ({ params, auth }) => {
handler: async ({ params, auth, req }) => {
const proxied = await proxy(
ctx,
auth.credentials.audience,
async (agent) => {
const result = await agent.api.app.bsky.feed.searchPosts(
params,
authPassthru(req),
)
return resultPassthru(result)
},
)
if (proxied !== null) {
return proxied
}

const requester = auth.credentials.did
const res = await ctx.appViewAgent.api.app.bsky.feed.searchPosts(
params,
await ctx.serviceAuthHeaders(requester),
const res = await proxyAppView(ctx, async (agent) =>
agent.api.app.bsky.feed.searchPosts(
params,
await ctx.serviceAuthHeaders(requester),
),
)
return {
encoding: 'application/json',
Expand Down

0 comments on commit 5630a12

Please sign in to comment.