my fork of the bluesky client
1/* eslint-disable-next-line no-restricted-imports */
2import {BSKY_LABELER_DID, moderatePost} from '@atproto/api'
3
4type ModeratePost = typeof moderatePost
5type Options = Parameters<ModeratePost>[1]
6
7export function moderatePost_wrapped(
8 subject: Parameters<ModeratePost>[0],
9 opts: Options,
10) {
11 // HACK
12 // temporarily translate 'gore' into 'graphic-media' during the transition period
13 // can remove this in a few months
14 // -prf
15 translateOldLabels(subject)
16
17 return moderatePost(subject, opts)
18}
19
20function translateOldLabels(subject: Parameters<ModeratePost>[0]) {
21 if (subject.labels) {
22 for (const label of subject.labels) {
23 if (
24 label.val === 'gore' &&
25 (!label.src || label.src === BSKY_LABELER_DID)
26 ) {
27 label.val = 'graphic-media'
28 }
29 }
30 }
31}