diff options
| author | Eric Bailey <git@esb.lol> | 2024-09-20 14:16:23 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-20 14:16:23 -0500 |
| commit | c85a271ef63ac006bf10f71adae102552298b661 (patch) | |
| tree | bdd21bf99a700904dd949bdf02d66ba5cfa0dc98 /src/state/session | |
| parent | 395edfe78f748b199be6417e9a2aac1482ac9bdc (diff) | |
| download | voidsky-c85a271ef63ac006bf10f71adae102552298b661.tar.zst | |
Additional moderation (#5172)
* Set up additional mod authorities * Filter out non-configurable mod authorities * WIP * Working * Cleanup, add mod * Cleanup * Add more debug logs * Tweak logs * Filter out imperative labels from typeaheads * Filter hideable content from notifications * Add api * Fall back in dev * Remove space * Use prod endpoint * Add tiny notice * Add notice to labeler card, show all labelers
Diffstat (limited to 'src/state/session')
| -rw-r--r-- | src/state/session/additional-moderation-authorities.ts | 41 | ||||
| -rw-r--r-- | src/state/session/moderation.ts | 4 |
2 files changed, 45 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}) +} diff --git a/src/state/session/moderation.ts b/src/state/session/moderation.ts index d8ded90f6..01684fe0b 100644 --- a/src/state/session/moderation.ts +++ b/src/state/session/moderation.ts @@ -1,6 +1,7 @@ import {BSKY_LABELER_DID, BskyAgent} from '@atproto/api' import {IS_TEST_USER} from '#/lib/constants' +import {configureAdditionalModerationAuthorities} from './additional-moderation-authorities' import {readLabelers} from './agent-config' import {SessionAccount} from './types' @@ -8,6 +9,7 @@ export function configureModerationForGuest() { // This global mutation is *only* OK because this code is only relevant for testing. // Don't add any other global behavior here! switchToBskyAppLabeler() + configureAdditionalModerationAuthorities() } export async function configureModerationForAccount( @@ -31,6 +33,8 @@ export async function configureModerationForAccount( // If there are no headers in the storage, we'll not send them on the initial requests. // If we wanted to fix this, we could block on the preferences query here. } + + configureAdditionalModerationAuthorities() } function switchToBskyAppLabeler() { |
