about summary refs log tree commit diff
path: root/src/lib/moderatePost_wrapped.ts
blob: 0ce01368af9a636d2ac876e71b308ab37eed4f2c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import {moderatePost, BSKY_LABELER_DID} from '@atproto/api'

type ModeratePost = typeof moderatePost
type Options = Parameters<ModeratePost>[1]

export function moderatePost_wrapped(
  subject: Parameters<ModeratePost>[0],
  opts: Options,
) {
  // HACK
  // temporarily translate 'gore' into 'graphic-media' during the transition period
  // can remove this in a few months
  // -prf
  translateOldLabels(subject)

  return moderatePost(subject, opts)
}

function translateOldLabels(subject: Parameters<ModeratePost>[0]) {
  if (subject.labels) {
    for (const label of subject.labels) {
      if (
        label.val === 'gore' &&
        (!label.src || label.src === BSKY_LABELER_DID)
      ) {
        label.val = 'graphic-media'
      }
    }
  }
}