Skip to content

Commit

Permalink
♻️ Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
foysalit committed Feb 21, 2025
1 parent 6772a91 commit f3ebe26
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions packages/ozone/src/api/moderation/emitEvent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isModEventDivert } from '@atproto/api/dist/client/types/tools/ozone/moderation/defs'
import { AuthRequiredError, InvalidRequestError } from '@atproto/xrpc-server'
import { AdminTokenOutput, ModeratorOutput } from '../../auth-verifier'
import { AppContext } from '../../context'
Expand All @@ -13,11 +14,8 @@ import {
isModEventTag,
isModEventTakedown,
isModEventUnmuteReporter,
validateModEventDivert,
validateModEventReport,
} from '../../lexicon/types/tools/ozone/moderation/defs'
import { HandlerInput } from '../../lexicon/types/tools/ozone/moderation/emitEvent'
import { asPredicate } from '../../lexicon/util'
import { subjectFromInput } from '../../mod-service/subject'
import { ProtectedTagSettingKey } from '../../setting/constants'
import { SettingService } from '../../setting/service'
Expand All @@ -26,9 +24,6 @@ import { TagService } from '../../tag-service'
import { getTagForReport } from '../../tag-service/util'
import { retryHttp } from '../../util'

const isValidModEventDivert = asPredicate(validateModEventDivert)
const isValidModEventReport = asPredicate(validateModEventReport)

const handleModerationEvent = async ({
ctx,
input,
Expand Down Expand Up @@ -132,7 +127,7 @@ const handleModerationEvent = async ({
)
}

if (isValidModEventDivert(event) && subject.isRecord()) {
if (isModEventDivert(event) && subject.isRecord()) {
if (!ctx.blobDiverter) {
throw new InvalidRequestError(
'BlobDiverter not configured for this service',
Expand Down Expand Up @@ -168,7 +163,7 @@ const handleModerationEvent = async ({
moderationTxn,
)

const initialTags = isValidModEventReport(event)
const initialTags = isModEventReport(event)
? [getTagForReport(event.reportType)]
: undefined
await tagService.evaluateForSubject(initialTags)
Expand Down Expand Up @@ -234,7 +229,7 @@ export default function (server: Server, ctx: AppContext) {
})

// On divert events, we need to automatically take down the blobs
if (isValidModEventDivert(input.body.event)) {
if (isModEventDivert(input.body.event)) {
await handleModerationEvent({
auth,
ctx,
Expand Down

0 comments on commit f3ebe26

Please sign in to comment.