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]) }