sendOneWeekBonusEmail logic
This commit is contained in:
parent
622f65e01e
commit
1185c91507
|
@ -14,7 +14,7 @@ import {
|
|||
cleanDisplayName,
|
||||
cleanUsername,
|
||||
} from '../../common/util/clean-username'
|
||||
import { sendWelcomeEmail } from './emails'
|
||||
import { sendOneWeekBonusEmail, sendWelcomeEmail } from './emails'
|
||||
import { isWhitelisted } from '../../common/envs/constants'
|
||||
import {
|
||||
CATEGORIES_GROUP_SLUG_POSTFIX,
|
||||
|
@ -95,8 +95,9 @@ export const createuser = newEndpoint(opts, async (req, auth) => {
|
|||
|
||||
await firestore.collection('private-users').doc(auth.uid).create(privateUser)
|
||||
|
||||
await sendWelcomeEmail(user, privateUser)
|
||||
await addUserToDefaultGroups(user)
|
||||
await sendWelcomeEmail(user, privateUser)
|
||||
await sendOneWeekBonusEmail(user, privateUser)
|
||||
await track(auth.uid, 'create user', { username }, { ip: req.ip })
|
||||
|
||||
return user
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import * as dayjs from 'dayjs'
|
||||
|
||||
import { DOMAIN } from '../../common/envs/constants'
|
||||
import { Answer } from '../../common/answer'
|
||||
import { Bet } from '../../common/bet'
|
||||
|
@ -165,7 +167,6 @@ export const sendWelcomeEmail = async (
|
|||
)
|
||||
}
|
||||
|
||||
// TODO: use manalinks to give out M$500
|
||||
export const sendOneWeekBonusEmail = async (
|
||||
user: User,
|
||||
privateUser: PrivateUser
|
||||
|
@ -183,6 +184,8 @@ export const sendOneWeekBonusEmail = async (
|
|||
const emailType = 'generic'
|
||||
const unsubscribeLink = `${UNSUBSCRIBE_ENDPOINT}?id=${userId}&type=${emailType}`
|
||||
|
||||
const oneWeek = dayjs().add(1, 'week').toString()
|
||||
|
||||
await sendTemplateEmail(
|
||||
privateUser.email,
|
||||
'Manifold one week anniversary gift',
|
||||
|
@ -190,10 +193,11 @@ export const sendOneWeekBonusEmail = async (
|
|||
{
|
||||
name: firstName,
|
||||
unsubscribeLink,
|
||||
manalink: '', // TODO
|
||||
manalink: 'https://manifold.markets/link/lj4JbBvE',
|
||||
},
|
||||
{
|
||||
from: 'David from Manifold <david@manifold.markets>',
|
||||
'o:deliverytime': oneWeek,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -26,9 +26,10 @@ export const sendTemplateEmail = (
|
|||
subject: string,
|
||||
templateId: string,
|
||||
templateData: Record<string, string>,
|
||||
options?: { from: string }
|
||||
options?: Partial<mailgun.messages.SendTemplateData>
|
||||
) => {
|
||||
const data = {
|
||||
const data: mailgun.messages.SendTemplateData = {
|
||||
...options,
|
||||
from: options?.from ?? 'Manifold Markets <info@manifold.markets>',
|
||||
to,
|
||||
subject,
|
||||
|
@ -36,6 +37,7 @@ export const sendTemplateEmail = (
|
|||
'h:X-Mailgun-Variables': JSON.stringify(templateData),
|
||||
}
|
||||
const mg = initMailgun()
|
||||
|
||||
return mg.messages().send(data, (error) => {
|
||||
if (error) console.log('Error sending email', error)
|
||||
else console.log('Sent template email', templateId, to, subject)
|
||||
|
|
Loading…
Reference in New Issue
Block a user