From 647ca6a9104b6a7a5278c062c68123555a43e424 Mon Sep 17 00:00:00 2001 From: Foysal Ahamed Date: Tue, 3 Oct 2023 17:01:43 +0200 Subject: [PATCH] :sparkles: Let admins see post thread even when the author blocks them (#1678) * :sparkles: Let admins see post thread even when the author blocks them * :recycle: Refactor requester check --- .../src/api/app/bsky/feed/getPostThread.ts | 4 ++-- .../src/api/app/bsky/feed/getPostThread.ts | 22 ++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/bsky/src/api/app/bsky/feed/getPostThread.ts b/packages/bsky/src/api/app/bsky/feed/getPostThread.ts index 0c26285b384..1480e54ac1a 100644 --- a/packages/bsky/src/api/app/bsky/feed/getPostThread.ts +++ b/packages/bsky/src/api/app/bsky/feed/getPostThread.ts @@ -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) diff --git a/packages/pds/src/api/app/bsky/feed/getPostThread.ts b/packages/pds/src/api/app/bsky/feed/getPostThread.ts index 3b719648f44..ab9e0bc0681 100644 --- a/packages/pds/src/api/app/bsky/feed/getPostThread.ts +++ b/packages/pds/src/api/app/bsky/feed/getPostThread.ts @@ -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,