Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118import {Client, type Service} from '@atproto/lex'
import {logger} from '#/logger'import {MOD_PROXY_DID} from '#/env'
export const BR_LABELER = 'did:plc:ekitcvx7uwnauoqy5oest3hm' // Brazilexport const DE_LABELER = 'did:plc:r55ow3tocux5kafs5dq445fy' // Germanyexport const RU_LABELER = 'did:plc:crm2agcxvvlj6hilnjdc4hox' // Russiaexport const GB_LABELER = 'did:plc:gvkp7euswjjrctjmqwhhfzif' // United Kingdomexport const AU_LABELER = 'did:plc:dsynw7isrf2eqlhcjx3ffnmt' // Australiaexport const TR_LABELER = 'did:plc:cquoj7aozvmkud2gifeinkda' // Turkeyexport const JP_LABELER = 'did:plc:vhgppeyjwgrr37vm4v6ggd5a' // Japanexport const ES_LABELER = 'did:plc:zlbbuj5nov4ixhvgl3bj47em' // Spainexport const PK_LABELER = 'did:plc:zrp6a3tvprrsgawsbswbxu7m' // Pakistanexport const IN_LABELER = 'did:plc:srr4rdvgzkbx6t7fxqtt6j5t' // India
/** * For all EU countries */export const EU_LABELER = 'did:plc:z57lz5dhgz2dkjogoysm3vut'
export const BLACKSKY_LABELER = 'did:plc:d2mkddsbmnrgr3domzg5qexf'
/** * This app's own moderation service: where its moderation inbox is read and * where appeals against its own takedowns go. The shared `MOD_PROXY_SERVICE` * defaults to Bluesky's, which stays right for chat and live access appeals. */export const BLACKSKY_MOD_SERVICE: Service = `${MOD_PROXY_DID || BLACKSKY_LABELER}#atproto_labeler`
const MODERATION_AUTHORITIES: { [countryCode: string]: string[]} = { BR: [BR_LABELER], // Brazil RU: [RU_LABELER], // Russia GB: [GB_LABELER], // United Kingdom AU: [AU_LABELER], // Australia TR: [TR_LABELER], // Turkey JP: [JP_LABELER], // Japan PK: [PK_LABELER], // Pakistan IN: [IN_LABELER], // India
// EU countries AT: [EU_LABELER], // Austria BE: [EU_LABELER], // Belgium BG: [EU_LABELER], // Bulgaria HR: [EU_LABELER], // Croatia CY: [EU_LABELER], // Cyprus CZ: [EU_LABELER], // Czech Republic DK: [EU_LABELER], // Denmark EE: [EU_LABELER], // Estonia FI: [EU_LABELER], // Finland FR: [EU_LABELER], // France DE: [EU_LABELER, DE_LABELER], // Germany GR: [EU_LABELER], // Greece HU: [EU_LABELER], // Hungary IE: [EU_LABELER], // Ireland IT: [EU_LABELER], // Italy LV: [EU_LABELER], // Latvia LT: [EU_LABELER], // Lithuania LU: [EU_LABELER], // Luxembourg MT: [EU_LABELER], // Malta NL: [EU_LABELER], // Netherlands PL: [EU_LABELER], // Poland PT: [EU_LABELER], // Portugal RO: [EU_LABELER], // Romania SK: [EU_LABELER], // Slovakia SI: [EU_LABELER], // Slovenia ES: [EU_LABELER, ES_LABELER], // Spain SE: [EU_LABELER], // Sweden}
const MODERATION_AUTHORITIES_DIDS = Array.from( new Set(Object.values(MODERATION_AUTHORITIES).flat()),)
export function isNonConfigurableModerationAuthority(did: string) { return MODERATION_AUTHORITIES_DIDS.includes(did)}
export function configureAdditionalModerationAuthorities() { // Only subscribe to the Blacksky labeler. Country labelers require geolocation // to apply correctly -- without it, subscribing to all of them causes labels // from irrelevant jurisdictions to block content for all users (e.g. a Brazil // labeler !hide on a US account would block that account for everyone). let additionalLabelers: string[] = []
additionalLabelers.push(BLACKSKY_LABELER) /* * Merge with whatever is already on the static rather than replacing it, so * `switchToBskyAppLabeler`'s entry survives. */ const appLabelers = Array.from( new Set<string>([...Client.appLabelers, ...additionalLabelers]), )
logger.info(`applying mod authorities`, { additionalLabelers, appLabelers, })
configureGlobalAppLabelers(appLabelers)}
/** * Set the global app labelers on the lex `Client` static, which every client * reads, so a request carries the same `;redact` authorities whether or not * there is a session behind it. * * It is a single global producer by design. The PDS client opts out with * `appLabelers: null` (see `clients.ts`) because that service takes no * moderation authorities. Appview and chat requests each carry one copy from * their respective clients. */export function configureGlobalAppLabelers(dids: string[]) { Client.configure({appLabelers: dids as `did:${string}:${string}`[]})}