From ac952f1164eda50459d5489a0a1cb2da12573e39 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Tue, 20 Sep 2022 15:49:46 -0500 Subject: [PATCH] Revert "Don't send creator guide email & interesting markets on create user" This reverts commit a4399aaee9a9a5bd79a2ce1add53a3ea991895fd. --- functions/src/on-create-user.ts | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/functions/src/on-create-user.ts b/functions/src/on-create-user.ts index f23d2f5b..844f75fc 100644 --- a/functions/src/on-create-user.ts +++ b/functions/src/on-create-user.ts @@ -4,8 +4,14 @@ import * as utc from 'dayjs/plugin/utc' dayjs.extend(utc) import { getPrivateUser } from './utils' -import { User } from '../../common/user' -import { sendPersonalFollowupEmail, sendWelcomeEmail } from './emails' +import { User } from 'common/user' +import { + sendCreatorGuideEmail, + sendInterestingMarketsEmail, + sendPersonalFollowupEmail, + sendWelcomeEmail, +} from './emails' +import { getTrendingContracts } from './weekly-markets-emails' export const onCreateUser = functions .runWith({ secrets: ['MAILGUN_KEY'] }) @@ -17,6 +23,23 @@ export const onCreateUser = functions await sendWelcomeEmail(user, privateUser) + const guideSendTime = dayjs().add(28, 'hours').toString() + await sendCreatorGuideEmail(user, privateUser, guideSendTime) + const followupSendTime = dayjs().add(48, 'hours').toString() await sendPersonalFollowupEmail(user, privateUser, followupSendTime) + + // skip email if weekly email is about to go out + const day = dayjs().utc().day() + if (day === 0 || (day === 1 && dayjs().utc().hour() <= 19)) return + + const contracts = await getTrendingContracts() + const marketsSendTime = dayjs().add(24, 'hours').toString() + + await sendInterestingMarketsEmail( + user, + privateUser, + contracts, + marketsSendTime + ) })