Fix birthday bug being perpetually snoozed (#9488)

This commit is contained in:
Eric Bailey
2025-12-05 12:17:43 -06:00
committed by GitHub
parent 89223d92d1
commit db81cefb86
2 changed files with 23 additions and 4 deletions
+14 -4
View File
@@ -15,7 +15,10 @@ import debounce from 'lodash.debounce'
import {networkRetry} from '#/lib/async/retry'
import {PUBLIC_BSKY_SERVICE} from '#/lib/constants'
import {getAge} from '#/lib/strings/time'
import {snoozeBirthdateUpdateAllowedForDid} from '#/state/birthdate'
import {
hasSnoozedBirthdateUpdateForDid,
snoozeBirthdateUpdateAllowedForDid,
} from '#/state/birthdate'
import {useAgent, useSession} from '#/state/session'
import * as debug from '#/ageAssurance/debug'
import {logger} from '#/ageAssurance/logger'
@@ -331,10 +334,17 @@ export async function getOtherRequiredData({
}
/**
* If the user is under the minimum age, and the birthdate is not due to
* the legacy bug, snooze further birthdate updates for this user.
* If the user is under the minimum age, and the birthdate is not due to the
* legacy bug, AND we've not already snoozed their birthdate update, snooze
* further birthdate updates for this user.
*
* This is basically a migration step for this initial rollout.
*/
if (data.birthdate && !isLegacyBirthdateBug(data.birthdate)) {
if (
data.birthdate &&
!isLegacyBirthdateBug(data.birthdate) &&
!hasSnoozedBirthdateUpdateForDid(did!)
) {
snoozeBirthdateUpdateAllowedForDid(did!)
}
+9
View File
@@ -20,6 +20,15 @@ export function snoozeBirthdateUpdateAllowedForDid(did: string) {
account.set([did, 'birthdateLastUpdatedAt'], new Date().toISOString())
}
/**
* Checks if we've already snoozed bday updates. In some cases, if one is
* present, we don't need to set another, such as in AA when reading initial
* data on load.
*/
export function hasSnoozedBirthdateUpdateForDid(did: string) {
return !!account.get([did, 'birthdateLastUpdatedAt'])
}
/**
* Returns whether a birthdate update is currently allowed, based on the
* last update timestamp stored locally.