Skip to content

Commit

Permalink
✨ Add ozone proxy for getLikes and getRepostedBy (#2624)
Browse files Browse the repository at this point in the history
* ✨ Add getLikes proxy through ozone

* ✨ Add getRepostedBy proxy

* 🧹 Cleanup

---------

Co-authored-by: Devin Ivy <[email protected]>
  • Loading branch information
foysalit and devinivy authored Jul 3, 2024
1 parent 1737d19 commit 34c1b9b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
8 changes: 6 additions & 2 deletions packages/bsky/src/api/app/bsky/feed/getLikes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ export default function (server: Server, ctx: AppContext) {
server.app.bsky.feed.getLikes({
auth: ctx.authVerifier.standardOptional,
handler: async ({ params, auth, req }) => {
const viewer = auth.credentials.iss
const { viewer, includeTakedowns } = ctx.authVerifier.parseCreds(auth)
const labelers = ctx.reqLabelers(req)
const hydrateCtx = await ctx.hydrator.createContext({ labelers, viewer })
const hydrateCtx = await ctx.hydrator.createContext({
labelers,
viewer,
includeTakedowns,
})
const result = await getLikes({ ...params, hydrateCtx }, ctx)

return {
Expand Down
8 changes: 6 additions & 2 deletions packages/bsky/src/api/app/bsky/feed/getRepostedBy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ export default function (server: Server, ctx: AppContext) {
server.app.bsky.feed.getRepostedBy({
auth: ctx.authVerifier.standardOptional,
handler: async ({ params, auth, req }) => {
const viewer = auth.credentials.iss
const { viewer, includeTakedowns } = ctx.authVerifier.parseCreds(auth)
const labelers = ctx.reqLabelers(req)
const hydrateCtx = await ctx.hydrator.createContext({ labelers, viewer })
const hydrateCtx = await ctx.hydrator.createContext({
labelers,
viewer,
includeTakedowns,
})
const result = await getRepostedBy({ ...params, hydrateCtx }, ctx)

return {
Expand Down
4 changes: 2 additions & 2 deletions packages/bsky/src/hydration/hydrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ export class Hydrator {
// - list basic
async hydrateLikes(uris: string[], ctx: HydrateCtx): Promise<HydrationState> {
const [likes, profileState] = await Promise.all([
this.feed.getLikes(uris),
this.feed.getLikes(uris, ctx.includeTakedowns),
this.hydrateProfiles(uris.map(didFromUri), ctx),
])
return mergeStates(profileState, { likes, ctx })
Expand All @@ -697,7 +697,7 @@ export class Hydrator {
// - list basic
async hydrateReposts(uris: string[], ctx: HydrateCtx) {
const [reposts, profileState] = await Promise.all([
this.feed.getReposts(uris),
this.feed.getReposts(uris, ctx.includeTakedowns),
this.hydrateProfiles(uris.map(didFromUri), ctx),
])
return mergeStates(profileState, { reposts, ctx })
Expand Down
28 changes: 28 additions & 0 deletions packages/ozone/src/api/proxied.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,34 @@ export default function (server: Server, ctx: AppContext) {
},
})

server.app.bsky.feed.getLikes({
auth: ctx.authVerifier.moderator,
handler: async (request) => {
const res = await ctx.appviewAgent.api.app.bsky.feed.getLikes(
request.params,
await ctx.appviewAuth(),
)
return {
encoding: 'application/json',
body: res.data,
}
},
})

server.app.bsky.feed.getRepostedBy({
auth: ctx.authVerifier.moderator,
handler: async (request) => {
const res = await ctx.appviewAgent.api.app.bsky.feed.getRepostedBy(
request.params,
await ctx.appviewAuth(),
)
return {
encoding: 'application/json',
body: res.data,
}
},
})

server.app.bsky.actor.searchActorsTypeahead({
auth: ctx.authVerifier.moderator,
handler: async (request) => {
Expand Down

0 comments on commit 34c1b9b

Please sign in to comment.