diff --git a/packages/component-manuscript-manager/src/notifications/emailCopy.js b/packages/component-manuscript-manager/src/notifications/emailCopy.js index f55b47978c32006a35b8d7a97a4a131ef51c8cb3..3819d77a5c80bfc82dc49ab8bb3a94d1b2facdc9 100644 --- a/packages/component-manuscript-manager/src/notifications/emailCopy.js +++ b/packages/component-manuscript-manager/src/notifications/emailCopy.js @@ -144,6 +144,12 @@ const getEmailCopy = ({ paragraph = `The authors of ${titleText} have submitted a revised version. <br/><br/> To review this new submission and proceed with the review process, please visit the manuscript details page.` break + case 'eic-revision-published': + hasIntro = false + hasSignature = false + paragraph = `The authors of ${titleText} have submitted a revised version. <br/><br/> + To review this new submission and proceed with the review process, please visit the manuscript details page.` + break default: throw new Error(`The ${emailType} email type is not defined.`) } diff --git a/packages/component-manuscript-manager/src/notifications/notification.js b/packages/component-manuscript-manager/src/notifications/notification.js index ff6c733a1eef5c52aab267747b5c384535fda11c..d80fb11f2c6a5b8486f9641d06b6bace4ff67cc8 100644 --- a/packages/component-manuscript-manager/src/notifications/notification.js +++ b/packages/component-manuscript-manager/src/notifications/notification.js @@ -629,6 +629,48 @@ class Notification { }) } + async notifyEditorInChiefWhenAuthorSubmitsRevision(newFragment) { + const { titleText } = await this._getNotificationProperties() + + const userHelper = new User({ UserModel: this.UserModel }) + const editors = await userHelper.getEditorsInChief() + + const { paragraph, ...bodyProps } = getEmailCopy({ + titleText, + emailType: 'eic-revision-published', + }) + + editors.forEach(eic => { + const email = new Email({ + type: 'user', + fromEmail: `${journalName} <${staffEmail}>`, + toUser: { + email: eic.email, + }, + content: { + subject: `${this.collection.customId}: Revision submitted`, + paragraph, + signatureName: '', + signatureJournal: journalName, + ctaLink: services.createUrl( + this.baseUrl, + `/projects/${this.collection.id}/versions/${ + newFragment.id + }/details`, + ), + ctaText: 'MANUSCRIPT DETAILS', + unsubscribeLink: services.createUrl(this.baseUrl, unsubscribeSlug, { + id: eic.id, + token: eic.accessTokens.unsubscribe, + }), + }, + bodyProps, + }) + + return email.sendEmail() + }) + } + async notifyReviewersWhenAuthorSubmitsMajorRevision(newFragmentId) { const { fragmentHelper } = await this._getNotificationProperties() const { collection, UserModel } = this diff --git a/packages/component-manuscript-manager/src/routes/fragments/strategies/eicRequestRevision.js b/packages/component-manuscript-manager/src/routes/fragments/strategies/eicRequestRevision.js index 671c507d14d2fc377015764e425c13787601ea05..7c89f6b93c8692e81178fb2c9b91f4a8f6957248 100644 --- a/packages/component-manuscript-manager/src/routes/fragments/strategies/eicRequestRevision.js +++ b/packages/component-manuscript-manager/src/routes/fragments/strategies/eicRequestRevision.js @@ -1,7 +1,13 @@ const { union } = require('lodash') module.exports = { - execute: async ({ models, TeamHelper, fragmentHelper, collectionHelper }) => { + execute: async ({ + models, + TeamHelper, + fragmentHelper, + collectionHelper, + notification, + }) => { const eicRequestToRevision = fragmentHelper.getLatestEiCRequestToRevision() if (!eicRequestToRevision) { throw new Error('No Editor in Chief request to revision has been found.') @@ -46,6 +52,8 @@ module.exports = { await collectionHelper.addFragment(newFragment.id) + await notification.notifyEditorInChiefWhenAuthorSubmitsRevision(newFragment) + return newFragment }, }