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