-
Notifications
You must be signed in to change notification settings - Fork 583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Let admins see post thread even when the author blocks them #1678
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,25 +22,41 @@ import { | |
getRepoRev, | ||
handleReadAfterWrite, | ||
} from '../util/read-after-write' | ||
import { authPassthru } from '../../../../../api/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 | ||
try { | ||
const res = await ctx.appviewAgent.api.app.bsky.feed.getPostThread( | ||
params, | ||
await ctx.serviceAuthHeaders(requester), | ||
) | ||
return await handleReadAfterWrite( | ||
ctx, | ||
requester, | ||
res, | ||
getPostThreadMunge, | ||
requester | ||
? await ctx.serviceAuthHeaders(requester) | ||
: authPassthru(req), | ||
) | ||
|
||
if (requester) { | ||
return await handleReadAfterWrite( | ||
ctx, | ||
requester, | ||
res, | ||
getPostThreadMunge, | ||
) | ||
} | ||
|
||
return { | ||
encoding: 'application/json', | ||
body: res.data, | ||
} | ||
} catch (err) { | ||
if (err instanceof AppBskyFeedGetPostThread.NotFoundError) { | ||
// TODO: is this right? checking for requester and error type is safe enough? | ||
if ( | ||
err instanceof AppBskyFeedGetPostThread.NotFoundError && | ||
requester | ||
) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I believe that should be fine 👍 Maybe there's a way to split the two cases-up more rather than have the 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,
}
}
// ...
// rest of code continues as originally written
// ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah yes, looks much better. just wasn't sure if the whole |
||
const local = await readAfterWriteNotFound( | ||
ctx, | ||
params, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed a build error that might be related to this—is it possible there's one too many
../
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm.. no idea how this happened though since it was auto-imported by vscode lol.