From 09e0dff301daf8367785f5f5dadffe3db123a07b Mon Sep 17 00:00:00 2001 From: Vika Date: Sat, 4 Apr 2026 03:10:11 +0300 Subject: [PATCH] Neuter age assurance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #98. Tested locally. Default moderation settings are still applied to logged-out accounts (per comments in the file, logged-out moderation settings are now downstream of AA code, ~~because bsky pbc are jerks like that~~ because it makes sense to keep everything in one place), but logged-in users are now afforded the freedom to choose their own moderation settings, as intended. I did not touch logged-out moderation prefs to avoid exposing users who might not yet have access to the moderation panel due to not having an account to anything objectionable — this, in my opinion, is sufficient balance considering AA is no longer functional for logged-in users. --- src/ageAssurance/state.ts | 66 +++++---------------------------------- 1 file changed, 8 insertions(+), 58 deletions(-) diff --git a/src/ageAssurance/state.ts b/src/ageAssurance/state.ts index f4d1e41e3..07616f116 100644 --- a/src/ageAssurance/state.ts +++ b/src/ageAssurance/state.ts @@ -1,5 +1,4 @@ import {useEffect, useMemo, useState} from 'react' -import {computeAgeAssuranceRegionAccess} from '@atproto/api' import {useSession} from '#/state/session' import {useAgeAssuranceDataContext} from '#/ageAssurance/data' @@ -8,10 +7,7 @@ import { AgeAssuranceAccess, type AgeAssuranceState, AgeAssuranceStatus, - parseAccessFromString, - parseStatusFromString, } from '#/ageAssurance/types' -import {getAgeAssuranceRegionConfigWithFallback} from '#/ageAssurance/util' import {useGeolocation} from '#/geolocation' export function useAgeAssuranceState(): AgeAssuranceState { @@ -30,62 +26,16 @@ export function useAgeAssuranceState(): AgeAssuranceState { access: AgeAssuranceAccess.Safe, } - /** - * This can happen if the prefetch fails (such as due to network issues). - * The query handler will try it again, but if it continues to fail, of - * course we won't have config. - * - * In this case, fail open to avoid blocking users. - */ - if (!config) { - logger.warn('useAgeAssuranceState: missing config') - return { - status: AgeAssuranceStatus.Unknown, - access: AgeAssuranceAccess.Safe, - error: 'config', - } - } - - const region = getAgeAssuranceRegionConfigWithFallback(config, geolocation) - const isAARequired = region.countryCode !== '*' - const isTerminalState = - state?.status === 'assured' || state?.status === 'blocked' - - /* - * If we are in a terminal state and AA is required for this region, - * we can trust the server state completely and avoid recomputing. - */ - if (isTerminalState && isAARequired) { - return { - lastInitiatedAt: state.lastInitiatedAt, - status: parseStatusFromString(state.status), - access: parseAccessFromString(state.access), - } - } - - /* - * Otherwise, we need to compute the access based on the latest data. For - * accounts with an accurate birthdate, our default fallback rules should - * ensure correct access. - */ - const result = computeAgeAssuranceRegionAccess(region, data) + // Don't baby the user. They know what they're doing. Age assurance is not + // mandatory in many regions, and there is no need to pander to bureaucrats + // when making FOSS software. You're free not to use this software if the + // notion of letting the user choose their moderation settings freely, + // without giving up their personal data to anyone, offends you. const computed = { - lastInitiatedAt: state?.lastInitiatedAt, - // prefer server state - status: state?.status - ? parseStatusFromString(state?.status) - : AgeAssuranceStatus.Unknown, - // prefer server state - access: result - ? parseAccessFromString(result.access) - : AgeAssuranceAccess.Full, + lastInitiatedAt: undefined, + status: AgeAssuranceStatus.Unknown, + access: AgeAssuranceAccess.Full, } - logger.debug('debug useAgeAssuranceState', { - region, - state, - data, - computed, - }) return computed }, [hasSession, geolocation, config, state, data]) } -- 2.51.2