Skip to content

Commit

Permalink
✨ Let admins see post thread even when the author blocks them (#1678)
Browse files Browse the repository at this point in the history
* ✨ Let admins see post thread even when the author blocks them

* ♻️ Refactor requester check
  • Loading branch information
foysalit authored Oct 3, 2023
1 parent 7d1e3b2 commit 647ca6a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/bsky/src/api/app/bsky/feed/getPostThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export default function (server: Server, ctx: AppContext) {
presentation,
)
server.app.bsky.feed.getPostThread({
auth: ctx.authOptionalVerifier,
auth: ctx.authOptionalAccessOrRoleVerifier,
handler: async ({ params, auth, res }) => {
const viewer = auth.credentials.did
const viewer = 'did' in auth.credentials ? auth.credentials.did : null
const db = ctx.db.getReplica('thread')
const feedService = ctx.services.feed(db)
const actorService = ctx.services.actor(db)
Expand Down
22 changes: 19 additions & 3 deletions packages/pds/src/api/app/bsky/feed/getPostThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,33 @@ import {
getRepoRev,
handleReadAfterWrite,
} from '../util/read-after-write'
import { authPassthru } from '../../../com/atproto/admin/util'

export default function (server: Server, ctx: AppContext) {
server.app.bsky.feed.getPostThread({
auth: ctx.accessVerifier,
handler: async ({ params, auth }) => {
const requester = auth.credentials.did
auth: ctx.accessOrRoleVerifier,
handler: async ({ req, params, auth }) => {
const requester =
auth.credentials.type === 'access' ? auth.credentials.did : null

if (!requester) {
const res = await ctx.appviewAgent.api.app.bsky.feed.getPostThread(
params,
authPassthru(req),
)

return {
encoding: 'application/json',
body: res.data,
}
}

try {
const res = await ctx.appViewAgent.api.app.bsky.feed.getPostThread(
params,
await ctx.serviceAuthHeaders(requester),
)

return await handleReadAfterWrite(
ctx,
requester,
Expand Down

0 comments on commit 647ca6a

Please sign in to comment.