2022-01-02 00:08:52 +00:00
|
|
|
import { sendEmail } from './send-email'
|
2022-01-10 21:07:57 +00:00
|
|
|
import { Contract } from '../../common/contract'
|
|
|
|
import { User } from '../../common/user'
|
2022-01-02 00:08:52 +00:00
|
|
|
import { getUser } from './utils'
|
|
|
|
|
|
|
|
export const sendMarketResolutionEmail = async (
|
|
|
|
userId: string,
|
|
|
|
payout: number,
|
|
|
|
creator: User,
|
|
|
|
contract: Contract,
|
2022-01-02 01:13:30 +00:00
|
|
|
resolution: 'YES' | 'NO' | 'CANCEL' | 'MKT'
|
2022-01-02 00:08:52 +00:00
|
|
|
) => {
|
|
|
|
const user = await getUser(userId)
|
|
|
|
if (!user) return
|
|
|
|
|
|
|
|
const subject = `Resolved ${toDisplayResolution[resolution]}: ${contract.question}`
|
|
|
|
|
|
|
|
const body = `Dear ${user.name},
|
|
|
|
|
|
|
|
A market you bet in has been resolved!
|
|
|
|
|
|
|
|
Creator: ${contract.creatorName}
|
|
|
|
Question: ${contract.question}
|
|
|
|
Resolution: ${toDisplayResolution[resolution]}
|
|
|
|
|
|
|
|
Your payout is M$ ${Math.round(payout)}
|
|
|
|
|
|
|
|
View the market here:
|
2022-01-06 18:48:30 +00:00
|
|
|
https://manifold.markets/${creator.username}/${contract.slug}
|
2022-01-02 00:08:52 +00:00
|
|
|
`
|
|
|
|
await sendEmail(user.email, subject, body)
|
|
|
|
}
|
|
|
|
|
2022-01-02 01:13:30 +00:00
|
|
|
const toDisplayResolution = { YES: 'YES', NO: 'NO', CANCEL: 'N/A', MKT: 'MKT' }
|