template email

This commit is contained in:
mantikoros 2022-02-16 18:46:21 -06:00
parent ffd14193b5
commit bf117aef46

View File

@ -1,7 +1,9 @@
import _ = require('lodash')
import { getProbability } from '../../common/calculate' import { getProbability } from '../../common/calculate'
import { Contract } from '../../common/contract' import { Contract } from '../../common/contract'
import { CREATOR_FEE } from '../../common/fees'
import { PrivateUser, User } from '../../common/user' import { PrivateUser, User } from '../../common/user'
import { formatPercent } from '../../common/util/format' import { formatMoney, formatPercent } from '../../common/util/format'
import { sendTemplateEmail, sendTextEmail } from './send-email' import { sendTemplateEmail, sendTextEmail } from './send-email'
import { getPrivateUser, getUser } from './utils' import { getPrivateUser, getUser } from './utils'
@ -93,20 +95,24 @@ export const sendMarketCloseEmail = async (
privateUser: PrivateUser, privateUser: PrivateUser,
contract: Contract contract: Contract
) => { ) => {
const firstName = user.name.split(' ')[0] const { username, name, id: userId } = user
const url = `https://manifold.markets/${user.username}/${contract.slug}` const firstName = name.split(' ')[0]
await sendTextEmail( const { question, pool: pools, slug } = contract
const pool = formatMoney(_.sum(_.values(pools)))
const url = `https://manifold.markets/${username}/${slug}`
await sendTemplateEmail(
privateUser.email || '', privateUser.email || '',
'Your market has closed', 'Your market has closed',
`Hi ${firstName}, 'market-close',
{
Trading for one of your markets has ended. Please resolve it as soon as possible. name: firstName,
question,
Question: ${contract.question} pool,
Url: ${url} url,
userId,
Best, creatorFee: (CREATOR_FEE * 100).toString(),
Austin from Manifold` }
) )
} }