From 6d0ac69a23fd14066f86e50a3d0f48536538a8f9 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 13 Mar 2024 12:49:26 -0700 Subject: [PATCH] Hackfix to translate gore labels to graphic-media --- src/lib/moderatePost_wrapped.ts | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/lib/moderatePost_wrapped.ts b/src/lib/moderatePost_wrapped.ts index d2a106995c..0ce01368af 100644 --- a/src/lib/moderatePost_wrapped.ts +++ b/src/lib/moderatePost_wrapped.ts @@ -1,9 +1,4 @@ -import {moderatePost} from '@atproto/api' - -// TODO -// do we think we'll need this again? -// if not we can ditch it! -// -prf +import {moderatePost, BSKY_LABELER_DID} from '@atproto/api' type ModeratePost = typeof moderatePost type Options = Parameters[1] @@ -12,5 +7,24 @@ export function moderatePost_wrapped( subject: Parameters[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[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' + } + } + } +}