about summary refs log tree commit diff
path: root/src/state/session/additional-moderation-authorities.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/state/session/additional-moderation-authorities.ts')
-rw-r--r--src/state/session/additional-moderation-authorities.ts41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/state/session/additional-moderation-authorities.ts b/src/state/session/additional-moderation-authorities.ts
new file mode 100644
index 000000000..c594294b2
--- /dev/null
+++ b/src/state/session/additional-moderation-authorities.ts
@@ -0,0 +1,41 @@
+import {BskyAgent} from '@atproto/api'
+
+import {logger} from '#/logger'
+import {device} from '#/storage'
+
+export const BR_LABELER = 'did:plc:ekitcvx7uwnauoqy5oest3hm'
+export const ADDITIONAL_LABELERS_MAP: {
+  [countryCode: string]: string[]
+} = {
+  BR: [BR_LABELER],
+}
+export const ALL_ADDITIONAL_LABELERS = Object.values(
+  ADDITIONAL_LABELERS_MAP,
+).flat()
+export const NON_CONFIGURABLE_LABELERS = [BR_LABELER]
+
+export function isNonConfigurableModerationAuthority(did: string) {
+  return NON_CONFIGURABLE_LABELERS.includes(did)
+}
+
+export function configureAdditionalModerationAuthorities() {
+  const geolocation = device.get(['geolocation'])
+  let additionalLabelers: string[] = ALL_ADDITIONAL_LABELERS
+
+  if (geolocation?.countryCode) {
+    additionalLabelers = ADDITIONAL_LABELERS_MAP[geolocation.countryCode] ?? []
+  } else {
+    logger.info(`no geolocation, cannot apply mod authorities`)
+  }
+
+  const appLabelers = Array.from(
+    new Set([...BskyAgent.appLabelers, ...additionalLabelers]),
+  )
+
+  logger.info(`applying mod authorities`, {
+    additionalLabelers,
+    appLabelers,
+  })
+
+  BskyAgent.configure({appLabelers})
+}