diff --git a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js index 5ee90e91eb8b2c8ba227c2f331ba49f61282bdfa..37010631d8164ca49b2692580a63ba4330385d97 100644 --- a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js +++ b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js @@ -1,6 +1,7 @@ const uuid = require('uuid') -const { pick, get } = require('lodash') +const { pick, get, set } = require('lodash') const config = require('config') +const { v4 } = require('uuid') const { services, @@ -90,6 +91,11 @@ module.exports = models => async (req, res) => { } await MTS.sendPackage({ fragment: packageFragment, isEQA: true }) + + collection.status = 'inQA' + set(collection, 'technicalChecks.token', v4()) + set(collection, 'technicalChecks.hasEQA', false) + await collection.save() } notifications.sendNotifications({ diff --git a/packages/component-manuscript-manager/src/routes/technicalChecks/notifications/emailCopy.js b/packages/component-manuscript-manager/src/routes/technicalChecks/notifications/emailCopy.js index 6d8160a84020bcc012a6b85c055acb0333b9cf8c..0c36acca52a116cc5f9584d0679a52944e635b02 100644 --- a/packages/component-manuscript-manager/src/routes/technicalChecks/notifications/emailCopy.js +++ b/packages/component-manuscript-manager/src/routes/technicalChecks/notifications/emailCopy.js @@ -1,4 +1,4 @@ -const getEmailCopy = ({ emailType, titleText }) => { +const getEmailCopy = ({ emailType, titleText, comments }) => { let paragraph let hasLink = true switch (emailType) { @@ -20,6 +20,10 @@ const getEmailCopy = ({ emailType, titleText }) => { paragraph = `Thank you for your review on ${titleText}. After taking into account the reviews and the recommendation of the Handling Editor, I can confirm this article will now be published.<br/><br/> If you have any queries about this decision, then please email them to Hindawi as soon as possible.` break + case 'eqa-manuscript-returned-to-eic': + paragraph = `We regret to inform you that ${titleText} has been returned with comments. Please click the link below to access the manuscript.<br/><br/> + Comments: ${comments}<br/><br/>` + break default: throw new Error(`The ${emailType} email type is not defined.`) } diff --git a/packages/component-manuscript-manager/src/routes/technicalChecks/notifications/notifications.js b/packages/component-manuscript-manager/src/routes/technicalChecks/notifications/notifications.js index c097ac5413afc9cf2b31cb959b1d7f4bb9aefaa9..5102aff7e058007aee527163380e23ddd43f2ba7 100644 --- a/packages/component-manuscript-manager/src/routes/technicalChecks/notifications/notifications.js +++ b/packages/component-manuscript-manager/src/routes/technicalChecks/notifications/notifications.js @@ -14,8 +14,10 @@ const unsubscribeSlug = config.get('unsubscribe.url') module.exports = { async sendNotifications({ isEQA, + agree, baseUrl, collection, + comments = '', User: UserModel, Fragment: FragmentModel, }) { @@ -50,7 +52,7 @@ module.exports = { }, }) - if (isEQA) { + if (isEQA && agree) { const eicName = await userHelper.getEiCName() email.content.signatureName = eicName sendAuthorsEmail({ @@ -76,17 +78,28 @@ module.exports = { subjectBaseText, }) } else { - sendEditorsEmail({ email, userHelper, titleText }) + sendEditorsEmail({ email, agree, comments, userHelper, titleText }) } }, } -const sendEditorsEmail = async ({ email, userHelper, titleText }) => { +const sendEditorsEmail = async ({ + email, + agree, + comments = '', + userHelper, + titleText, +}) => { + const emailType = agree + ? 'eqs-manuscript-accepted' + : 'eqa-manuscript-returned-to-eic' + const editors = (await userHelper.getEditorsInChief()).map(eic => ({ ...eic, ...getEmailCopy({ - emailType: 'eqs-manuscript-accepted', + emailType, titleText, + comments, }), })) diff --git a/packages/component-manuscript-manager/src/routes/technicalChecks/patch.js b/packages/component-manuscript-manager/src/routes/technicalChecks/patch.js index f959d3809ae5aa94c11d1e06aed35c11fb324ebe..3e6061fd3c42e9077eca698b5fb8ae67c75f0c0e 100644 --- a/packages/component-manuscript-manager/src/routes/technicalChecks/patch.js +++ b/packages/component-manuscript-manager/src/routes/technicalChecks/patch.js @@ -18,7 +18,7 @@ const setNewStatus = (step, agree) => { module.exports = ({ Collection, Fragment, User }) => async (req, res) => { const { collectionId } = req.params - const { token, agree, step } = req.body + const { token, agree, step, comments } = req.body try { const collection = await Collection.find(collectionId) @@ -43,15 +43,15 @@ module.exports = ({ Collection, Fragment, User }) => async (req, res) => { collection.status = setNewStatus(step, agree) await collection.save() - if (agree) { - sendNotifications({ - User, - Fragment, - collection, - baseUrl: services.getBaseUrl(req), - isEQA: step === TECHNICAL_STEPS.EQA, - }) - } + sendNotifications({ + User, + agree, + comments, + Fragment, + collection, + baseUrl: services.getBaseUrl(req), + isEQA: step === TECHNICAL_STEPS.EQA, + }) return res.status(200).json(collection) } catch (e) {