From 278aa732368b0c8d1aaa0d9bef6631755aac77a1 Mon Sep 17 00:00:00 2001 From: Mihail Hagiu <mihail.hagiu@thinslices.com> Date: Mon, 3 Dec 2018 14:54:13 +0200 Subject: [PATCH] feat(AuthorEmailEiCRequestRevision): Created email template for author when eic requests revision --- .../src/notifications/emailCopy.js | 5 ++ .../src/notifications/notification.js | 47 +++++++++++++++++++ .../strategies/eicRequestRevision.js | 8 +++- 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/packages/component-manuscript-manager/src/notifications/emailCopy.js b/packages/component-manuscript-manager/src/notifications/emailCopy.js index f55b47978..a89444435 100644 --- a/packages/component-manuscript-manager/src/notifications/emailCopy.js +++ b/packages/component-manuscript-manager/src/notifications/emailCopy.js @@ -144,6 +144,11 @@ 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 'author-request-to-revision-from-eic': + paragraph = `In order for ${titleText} to proceed to the review proess, there needs to be a revision. <br/><br/> + ${comments}<br/><br/> + For more information about what is required, please click the link below.<br/><br/>` + 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 ff6c733a1..4f83121b0 100644 --- a/packages/component-manuscript-manager/src/notifications/notification.js +++ b/packages/component-manuscript-manager/src/notifications/notification.js @@ -407,6 +407,53 @@ class Notification { return email.sendEmail() } + async notifySAWhenEiCRequestsRevision() { + const { + eicName, + submittingAuthor, + titleText, + } = await this._getNotificationProperties() + + const authorNoteText = helpers.getPrivateNoteTextForAuthor({ + newRecommendation: this.newRecommendation, + }) + + const { paragraph, ...bodyProps } = getEmailCopy({ + emailType: 'author-request-to-revision', + titleText, + comments: authorNoteText, + }) + + const email = new Email({ + type: 'user', + toUser: { + email: submittingAuthor.email, + name: submittingAuthor.lastName, + }, + fromEmail: `${eicName} <${staffEmail}>`, + content: { + subject: `${this.collection.customId}: Revision requested`, + paragraph, + signatureName: eicName, + ctaText: 'MANUSCRIPT DETAILS', + signatureJournal: journalName, + unsubscribeLink: services.createUrl(this.baseUrl, unsubscribeSlug, { + id: submittingAuthor.id, + token: submittingAuthor.accessTokens.unsubscribe, + }), + ctaLink: services.createUrl( + this.baseUrl, + `/projects/${this.collection.id}/versions/${ + this.fragment.id + }/details`, + ), + }, + bodyProps, + }) + + return email.sendEmail() + } + async notifyReviewersWhenHEMakesRecommendation() { const { eicName, diff --git a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/strategies/eicRequestRevision.js b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/strategies/eicRequestRevision.js index a98304d7a..0f66d8af7 100644 --- a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/strategies/eicRequestRevision.js +++ b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/strategies/eicRequestRevision.js @@ -1,5 +1,10 @@ module.exports = { - execute: async ({ fragmentHelper, collectionHelper, newRecommendation }) => { + execute: async ({ + fragmentHelper, + collectionHelper, + newRecommendation, + notification, + }) => { if (collectionHelper.hasHandlingEditor()) { throw new Error( 'Cannot make request a revision after a Handling Editor has been assigned.', @@ -9,5 +14,6 @@ module.exports = { await fragmentHelper.addRevision() await collectionHelper.updateStatus({ newStatus: 'revisionRequested' }) await fragmentHelper.addRecommendation(newRecommendation) + await notification.notifySAWhenEiCRequestsRevision() }, } -- GitLab