-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
additional-moderation-authorities.ts
43 lines (35 loc) · 1.2 KB
/
additional-moderation-authorities.ts
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
31
32
33
34
35
36
37
38
39
40
41
42
43
import {BskyAgent} from '@atproto/api'
import {logger} from '#/logger'
import {device} from '#/storage'
export const BR_LABELER = 'did:plc:ekitcvx7uwnauoqy5oest3hm'
export const DE_LABELER = 'did:plc:r55ow3tocux5kafs5dq445fy'
export const ADDITIONAL_LABELERS_MAP: {
[countryCode: string]: string[]
} = {
BR: [BR_LABELER],
DE: [DE_LABELER],
}
export const ALL_ADDITIONAL_LABELERS = Object.values(
ADDITIONAL_LABELERS_MAP,
).flat()
export const NON_CONFIGURABLE_LABELERS = [BR_LABELER, DE_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})
}