Skip to content
Snippets Groups Projects
Commit ed9d8945 authored by Audrey Hamelers's avatar Audrey Hamelers
Browse files

#422

parent aa92bb83
No related branches found
No related tags found
2 merge requests!112Shared data model,!113Dev
const config = require('config')
const Email = require('@pubsweet/component-send-email')
const lodash = require('lodash')
const logger = require('@pubsweet/logger')
const {
htmlEmailBase,
......@@ -19,6 +20,8 @@ const {
const tagger = config.ftp_tagger.email
const { sender, url, testAddress, system, dev } = config['epmc-email']
const parsed = string => lodash.unescape(string)
const sendMail = (to, subject, message, from = null, cc = null, bcc = null) => {
const mailData = {
from: from || sender,
......@@ -54,13 +57,13 @@ const taggerErrorEmail = (subject, message) => {
}
const taggerEmail = (email, manId, title, link) => {
const html = newPackageForTaggingTemplate(manId, title, link)
const html = newPackageForTaggingTemplate(manId, parsed(title), link)
const subject = 'New Package Available for Tagging'
sendMail(email, subject, html, null, null, system)
}
const processedTaggerEmail = (email, manId, title, packageName) => {
const html = processedTaggingFilesTemplate(manId, title, packageName)
const html = processedTaggingFilesTemplate(manId, parsed(title), packageName)
const subject = 'Tagging files have been uploaded'
sendMail(email, subject, html, null, null, system)
}
......@@ -88,15 +91,16 @@ const reviewerEmail = ({ reviewer, manInfo, submitter, token }) => {
const submitterName = `${title ? `${title} ` : ''}${givenNames} ${surname}`
const { title: t, givenNames: g, surname: s } = reviewer.name
const salutation = `${t ? `${t} ` : ''}${g} ${s}`
let link = `${url}submission/${manInfo.id}/submit`
const link = `${url}submission/${manInfo.id}/submit`
const args = [salutation, parsed(manInfo.title), submitterName, link]
let html = ''
if (token === 'correction') {
html = checkReviewerTemplate(salutation, manInfo.title, submitterName, link)
html = checkReviewerTemplate(...args)
} else if (reviewer.id) {
html = setReviewerTemplate(salutation, manInfo.title, submitterName, link)
html = setReviewerTemplate(...args)
} else {
link = `${url}dashboard?accept=${token}`
html = newReviewerTemplate(salutation, manInfo.title, submitterName, link)
args[4] = `${url}dashboard?accept=${token}`
html = newReviewerTemplate(...args)
}
const subject = `Approve submission of ${manInfo.id}`
sendMail(reviewer.email, subject, html, null, null, system)
......@@ -111,7 +115,7 @@ const submitterRejectEmail = ({ reviewer, manInfo, submitter, message }) => {
const link = `${url}submission/${manInfo.id}/submit`
const html = rejectSubmissionTemplate(
salutation,
manInfo.title,
parsed(manInfo.title),
reviewerName,
message,
link,
......@@ -132,7 +136,7 @@ const removeDuplicateEmail = (user, badInfo, goodInfo) => {
const html = removeDupeTemplate(
salutation,
badInfo.id,
badInfo['meta,title'],
parsed(badInfo['meta,title']),
goodInfo.id,
pmcid,
)
......@@ -153,7 +157,7 @@ const finalReviewEmail = (reviewer, manInfo) => {
}`
const html = finalReviewTemplate(
salutation,
manInfo.title,
parsed(manInfo.title),
link,
releaseDelay,
)
......
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