Skip to content
Snippets Groups Projects
Commit 6b269fb7 authored by ahamelers's avatar ahamelers
Browse files

add system bcc to system emails

parent 746e95fe
No related branches found
No related tags found
2 merge requests!75Shared data model,!77Dev
......@@ -164,7 +164,8 @@ module.exports = {
url: process.env.PUBSWEET_URL || 'http://localhost:3000/',
sender: process.env.PUBSWEET_SENDER || 'helpdesk@europepmc.org',
testAddress: process.env.PUBSWEET_TEST_EMAIL || 'plusdev@ebi.ac.uk',
// change 'plusdev@ebi.ac.uk' to blank string for production
// remove PUBSWEET_TEST_EMAIL and change 'plusdev@ebi.ac.uk' to blank string for production
system: process.env.PUBSWEET_SYSTEM_EMAIL || 'plusadmin@ebi.ac.uk',
},
'pubsweet-component-ink-backend': {
inkEndpoint:
......
......@@ -13,18 +13,23 @@ const {
finalReviewTemplate,
} = require('./templates')
const { sender, url, testAddress } = config['epmc-email']
const { sender, url, testAddress, system } = config['epmc-email']
const sendMail = (to, subject, message, from = null, cc = null) => {
logger.info(`Email recipient: ${to}`)
const sendMail = (to, subject, message, from = null, cc = null, bcc = null) => {
const mailData = {
from: from || sender,
to: testAddress || to,
subject: `[Europe PMC plus] ${subject}`,
html: htmlEmailBase(message, url),
}
logger.info(`Email recipient: ${to}`)
if (cc) {
mailData.cc = testAddress || cc
logger.info(`Email CC: ${cc}`)
}
if (bcc) {
mailData.bcc = testAddress || bcc
logger.info(`Email BCC: ${bcc}`)
}
Email.send(mailData)
}
......@@ -41,14 +46,14 @@ const userMessage = (email, subject, message, from = null) => {
const taggerEmail = (email, manId, title, link) => {
const html = newPackageForTaggingTemplate(manId, title, link)
sendMail(email, 'New Package Available for Tagging', html)
const subject = 'New Package Available for Tagging'
sendMail(email, subject, html, null, null, system)
}
const bulkUploaderEmail = (email, message) => {
const html = bulkUploadTemplate(message)
sendMail(email, 'Error while processing package', html)
const subject = 'Error while processing package'
sendMail(email, subject, html, null, null, system)
}
const reviewerEmail = ({ reviewer, manInfo, submitter, token }) => {
......@@ -67,7 +72,7 @@ const reviewerEmail = ({ reviewer, manInfo, submitter, token }) => {
html = newReviewerTemplate(salutation, manInfo.title, submitterName, link)
}
const subject = `Approve submission of ${manInfo.id}`
sendMail(reviewer.email, subject, html)
sendMail(reviewer.email, subject, html, null, null, system)
}
const submitterRejectEmail = ({ reviewer, manInfo, submitter, message }) => {
......@@ -85,7 +90,7 @@ const submitterRejectEmail = ({ reviewer, manInfo, submitter, message }) => {
link,
)
const subject = `${manInfo.id}: Submission rejected`
sendMail(email, subject, html)
sendMail(email, subject, html, null, null, system)
}
const removeDuplicateEmail = (user, badInfo, goodInfo) => {
......@@ -105,7 +110,7 @@ const removeDuplicateEmail = (user, badInfo, goodInfo) => {
pmcid,
)
const subject = `${badInfo.id}: Duplicate submission`
sendMail(email, subject, html)
sendMail(email, subject, html, null, null, system)
}
const finalReviewEmail = (reviewer, manInfo) => {
......@@ -126,7 +131,7 @@ const finalReviewEmail = (reviewer, manInfo) => {
releaseDelay,
)
const subject = `${manInfo.id}: Ready for final review`
sendMail(email, subject, html)
sendMail(email, subject, html, null, null, system)
}
module.exports = {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment