Fix fr comment emails (#247)
* Get answer outcome from comment * Avoid db call if possible * Include general comments note in comment emails * Send market-comment on general comment
This commit is contained in:
parent
5adf430fad
commit
84c86552d5
|
@ -244,7 +244,8 @@ export const sendNewCommentEmail = async (
|
|||
contract: Contract,
|
||||
comment: Comment,
|
||||
bet?: Bet,
|
||||
answer?: Answer
|
||||
answerText?: string,
|
||||
answerId?: string
|
||||
) => {
|
||||
const privateUser = await getPrivateUser(userId)
|
||||
if (
|
||||
|
@ -273,9 +274,8 @@ export const sendNewCommentEmail = async (
|
|||
const subject = `Comment on ${question}`
|
||||
const from = `${commentorName} <info@manifold.markets>`
|
||||
|
||||
if (contract.outcomeType === 'FREE_RESPONSE') {
|
||||
const answerText = answer?.text ?? ''
|
||||
const answerNumber = `#${answer?.id ?? ''}`
|
||||
if (contract.outcomeType === 'FREE_RESPONSE' && answerId && answerText) {
|
||||
const answerNumber = `#${answerId}`
|
||||
|
||||
await sendTemplateEmail(
|
||||
privateUser.email,
|
||||
|
|
|
@ -34,7 +34,14 @@ export const onCreateComment = functions.firestore
|
|||
|
||||
let bet: Bet | undefined
|
||||
let answer: Answer | undefined
|
||||
if (comment.betId) {
|
||||
if (comment.answerOutcome) {
|
||||
answer =
|
||||
contract.outcomeType === 'FREE_RESPONSE' && contract.answers
|
||||
? contract.answers?.find(
|
||||
(answer) => answer.id === comment.answerOutcome
|
||||
)
|
||||
: undefined
|
||||
} else if (comment.betId) {
|
||||
const betSnapshot = await firestore
|
||||
.collection('contracts')
|
||||
.doc(contractId)
|
||||
|
@ -66,7 +73,8 @@ export const onCreateComment = functions.firestore
|
|||
contract,
|
||||
comment,
|
||||
bet,
|
||||
answer
|
||||
answer?.text,
|
||||
answer?.id
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user