Files
cloud-mail/mail-worker/src/template/email-msg.js

42 lines
771 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import emailUtils from '../utils/email-utils';
export default function emailMsgTemplate(email, tgMsgTo, tgMsgFrom, tgMsgText) {
let template = `<b>${email.subject}</b>`
if (tgMsgFrom === 'only-name') {
template += `
From\u200B${email.name}`
}
if (tgMsgFrom === 'show') {
template += `
From\u200B${email.name} &lt;${email.sendEmail}&gt;`
}
if(tgMsgTo === 'show' && tgMsgFrom === 'hide') {
template += `
To\u200B${email.toEmail}`
} else if(tgMsgTo === 'show') {
template += `
To\u200B${email.toEmail}`
}
const text = (emailUtils.formatText(email.text) || emailUtils.htmlToText(email.content))
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
if(tgMsgText === 'show') {
template += `
${text}`
}
return template;
}