From c16e5189f71207895164465f58263a70ead9e78f Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Fri, 30 Sep 2022 07:53:47 -0600 Subject: [PATCH] Don't send portfolio email to user less than 5 days old --- functions/src/weekly-portfolio-emails.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/src/weekly-portfolio-emails.ts b/functions/src/weekly-portfolio-emails.ts index 0167be35..ab46c5f1 100644 --- a/functions/src/weekly-portfolio-emails.ts +++ b/functions/src/weekly-portfolio-emails.ts @@ -117,7 +117,8 @@ export async function sendPortfolioUpdateEmailsToAllUsers() { await Promise.all( privateUsersToSendEmailsTo.map(async (privateUser) => { const user = await getUser(privateUser.id) - if (!user) return + // Don't send to a user unless they're over 5 days old + if (!user || user.createdTime > Date.now() - 5 * DAY_MS) return const userBets = usersBets[privateUser.id] as Bet[] const contractsUserBetOn = contractsUsersBetOn.filter((contract) => userBets.some((bet) => bet.contractId === contract.id)