feat(notifications): wire pruneDeadTokens into reengagement

This commit is contained in:
null 2026-06-30 23:35:49 -05:00
parent 35eca7d08d
commit e35b8151c6
1 changed files with 3 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import * as functions from 'firebase-functions' import * as functions from 'firebase-functions'
import * as admin from 'firebase-admin' import * as admin from 'firebase-admin'
import { recipientInQuietHours } from './quietHours' import { recipientInQuietHours } from './quietHours'
import { pruneDeadTokens } from './pruneTokens'
const THREE_DAYS_MS = 3 * 24 * 60 * 60 * 1000 const THREE_DAYS_MS = 3 * 24 * 60 * 60 * 1000
const TEN_DAYS_MS = 10 * 24 * 60 * 60 * 1000 const TEN_DAYS_MS = 10 * 24 * 60 * 60 * 1000
@ -102,7 +103,7 @@ async function sendNudge(
const tokens = await getUserTokens(db, userId, userData) const tokens = await getUserTokens(db, userId, userData)
if (tokens.length === 0) return if (tokens.length === 0) return
await Promise.allSettled( const results = await Promise.allSettled(
tokens.map((token) => tokens.map((token) =>
messaging.send({ messaging.send({
token, token,
@ -118,6 +119,7 @@ async function sendNudge(
}) })
) )
) )
await pruneDeadTokens(db, userId, tokens, results)
} }
async function getUserTokens( async function getUserTokens(