Skip to content

Commit

Permalink
Allow optional auth for reporting on bsky appview (#1215)
Browse files Browse the repository at this point in the history
temporarily accept anonymous reports on bsky appview
  • Loading branch information
devinivy committed Jun 19, 2023
1 parent 6a1b24f commit 104799f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/bsky/src/api/com/atproto/moderation/createReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ import { softDeleted } from '../../../../db/util'

export default function (server: Server, ctx: AppContext) {
server.com.atproto.moderation.createReport({
auth: ctx.authVerifier,
// @TODO anonymous reports w/ optional auth are a temporary measure
auth: ctx.authOptionalVerifier,
handler: async ({ input, auth }) => {
const { db, services } = ctx
const { reasonType, reason, subject } = input.body
const requester = auth.credentials.did

// Don't accept reports from users that are fully taken-down
const actor = await services.actor(db).getActor(requester, true)
if (actor && softDeleted(actor)) {
throw new AuthRequiredError()
if (requester) {
// Don't accept reports from users that are fully taken-down
const actor = await services.actor(db).getActor(requester, true)
if (actor && softDeleted(actor)) {
throw new AuthRequiredError()
}
}

const moderationService = services.moderation(db)
Expand All @@ -24,7 +27,7 @@ export default function (server: Server, ctx: AppContext) {
reasonType: getReasonType(reasonType),
reason,
subject: getSubject(subject),
reportedBy: requester,
reportedBy: requester || ctx.cfg.serverDid,
})

return {
Expand Down

0 comments on commit 104799f

Please sign in to comment.