Send a welcome email to new users
This commit is contained in:
parent
096ac8f512
commit
66624ff92c
|
@ -13,6 +13,7 @@ import {
|
|||
cleanDisplayName,
|
||||
cleanUsername,
|
||||
} from '../../common/util/clean-username'
|
||||
import { sendWelcomeEmail } from './emails'
|
||||
|
||||
export const createUser = functions
|
||||
.runWith({ minInstances: 1 })
|
||||
|
@ -79,6 +80,8 @@ export const createUser = functions
|
|||
|
||||
await firestore.collection('private-users').doc(userId).create(privateUser)
|
||||
|
||||
await sendWelcomeEmail(user, privateUser)
|
||||
|
||||
return { status: 'success', user }
|
||||
})
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { getProbability } from '../../common/calculate'
|
||||
import { Contract } from '../../common/contract'
|
||||
import { User } from '../../common/user'
|
||||
import { PrivateUser, User } from '../../common/user'
|
||||
import { formatPercent } from '../../common/util/format'
|
||||
import { sendTemplateEmail } from './send-email'
|
||||
import { sendTemplateEmail, sendTextEmail } from './send-email'
|
||||
import { getPrivateUser, getUser } from './utils'
|
||||
|
||||
type market_resolved_template = {
|
||||
|
@ -67,3 +67,23 @@ export const sendMarketResolutionEmail = async (
|
|||
templateData
|
||||
)
|
||||
}
|
||||
|
||||
export const sendWelcomeEmail = async (
|
||||
user: User,
|
||||
privateUser: PrivateUser
|
||||
) => {
|
||||
const firstName = user.name.split(' ')[0]
|
||||
|
||||
await sendTextEmail(
|
||||
privateUser.email || '',
|
||||
'Welcome to Manifold Markets!',
|
||||
`Hi ${firstName},
|
||||
|
||||
Thanks for joining us! We can't wait to see what markets you create.
|
||||
Questions? Feedback? I'd love to hear from you - just reply to this email!
|
||||
Or come chat with us on Discord: https://discord.gg/eHQBNBqXuh
|
||||
|
||||
Best,
|
||||
Austin from Manifold`
|
||||
)
|
||||
}
|
||||
|
|
|
@ -5,11 +5,13 @@ const DOMAIN = 'mg.manifold.markets'
|
|||
const mg = mailgun({ apiKey: functions.config().mailgun.key, domain: DOMAIN })
|
||||
|
||||
export const sendTextEmail = (to: string, subject: string, text: string) => {
|
||||
const data = {
|
||||
from: 'Manifold Markets <no-reply@manifold.markets>',
|
||||
const data: mailgun.messages.SendData = {
|
||||
from: 'Manifold Markets <info@manifold.markets>',
|
||||
to,
|
||||
subject,
|
||||
text,
|
||||
// Don't rewrite urls in plaintext emails
|
||||
'o:tracking-clicks': 'htmlonly',
|
||||
}
|
||||
|
||||
return mg.messages().send(data, (error) => {
|
||||
|
@ -25,7 +27,7 @@ export const sendTemplateEmail = (
|
|||
templateData: Record<string, string>
|
||||
) => {
|
||||
const data = {
|
||||
from: 'Manifold Markets <no-reply@manifold.markets>',
|
||||
from: 'Manifold Markets <info@manifold.markets>',
|
||||
to,
|
||||
subject,
|
||||
template: templateId,
|
||||
|
|
Loading…
Reference in New Issue
Block a user