Commit 385d193d authored by Audrey Hamelers's avatar Audrey Hamelers
parent 7ebf8480
Pipeline #12957 passed with stages
in 5 minutes and 37 seconds
......@@ -21,6 +21,7 @@ const {
incompleteTemplate,
stalledTemplate,
stalledErrorTemplate,
deletedTemplate,
} = require('./templates')
const tagger = config.ftp_tagger.email
......@@ -104,6 +105,12 @@ const completedEmail = (email, manInfo) => {
sendMail(email, subject, html, null, null, system)
}
const deletedEmail = (email, manInfo) => {
const html = deletedTemplate(manInfo.title)
const subject = `${manInfo.id}: Submission cancelled`
sendMail(email, subject, html, null, null, system)
}
const incompleteEmail = (manInfo, submitter) => {
const { title, givenNames, surname } = submitter
const { email } = submitter.identities[0]
......@@ -263,6 +270,7 @@ module.exports = {
alreadyCompleteEmail,
finalReviewEmail,
completedEmail,
deletedEmail,
resetPassword,
incompleteEmail,
stalledEmail,
......
const deletedTemplate = title => `
<h1 style="font-weight:600;">Submisson cancelled</h1>
<p>This manuscript submission, <b>${title}</b>, was cancelled by its submitter and removed from our system. No further action is required.</p>
<p>If this submission was cancelled in error, please let us know by replying to this message, or use the contact information below.</p>
<p>Kind regards,</p>
<p>The Europe PMC Helpdesk</p>
`
module.exports = { deletedTemplate }
......@@ -17,6 +17,7 @@ const {
} = require('./ftp')
const { finalReviewTemplate } = require('./finalReview')
const { completedTemplate } = require('./completed')
const { deletedTemplate } = require('./deleted')
const {
incompleteTemplate,
stalledTemplate,
......@@ -99,6 +100,7 @@ module.exports = {
errorDevTemplate,
bulkUploadTemplate,
completedTemplate,
deletedTemplate,
incompleteTemplate,
stalledTemplate,
stalledErrorTemplate,
......
......@@ -22,6 +22,7 @@ const {
alreadyCompleteEmail,
finalReviewEmail,
taggerErrorEmail,
deletedEmail,
} = rfr('server/email')
const grantCheck = (origMan, changeMan) => {
......@@ -206,6 +207,34 @@ const Manuscript = {
delete: async (id, userId) => {
try {
const manuscript = await ManuscriptAccess.selectById(id)
const teams = await Team.selectByManuscriptId(id)
const subTeam = teams.find(t => t.roleName === 'submitter')
if (userId === subTeam.userId) {
logger.info('Sending deleted notification email')
const submitter = await UserAccess.findById(subTeam.userId)
const emails = submitter ? [submitter.identities[0].email] : []
const revTeam = teams.find(t => t.roleName === 'reviewer')
if (revTeam && revTeam.userId !== subTeam.userId) {
const reviewer = await UserAccess.findById(revTeam.userId)
if (reviewer) {
emails.push(reviewer.identities[0].email)
}
} else {
const notes = await NoteAccess.selectByManuscriptId(id)
const reviewerNote = notes.find(
n => n.notesType === 'selectedReviewer',
)
const reviewer = reviewerNote && JSON.parse(reviewerNote.content)
if (reviewer && (!reviewer.id || reviewer.id !== subTeam.id)) {
emails.push(reviewer.email)
}
}
const manInfo = {
id,
title: manuscript['meta,title'],
}
await deletedEmail(emails, manInfo)
}
if (manuscript) {
await ManuscriptAccess.delete(id, userId)
return true
......
Markdown is supported
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