From 9fa5d575b9417ab7c15119e62a30ebca7e615d51 Mon Sep 17 00:00:00 2001
From: Sebastian Mihalache <sebastian.mihalache@gmail.con>
Date: Fri, 7 Sep 2018 15:35:17 +0300
Subject: [PATCH] feat(component-invite): update reviewers emails

---
 .../email/templates/partials/signature.hbs    |  3 +-
 .../fragmentsInvitations/emails/emailCopy.js  | 52 +++++++++----------
 .../emails/invitations.js                     | 28 ++++++----
 .../emails/notifications.js                   | 26 +++++-----
 packages/xpub-faraday/config/default.js       |  4 ++
 5 files changed, 61 insertions(+), 52 deletions(-)

diff --git a/packages/component-helper-service/src/services/email/templates/partials/signature.hbs b/packages/component-helper-service/src/services/email/templates/partials/signature.hbs
index 615770e16..34a25ed42 100644
--- a/packages/component-helper-service/src/services/email/templates/partials/signature.hbs
+++ b/packages/component-helper-service/src/services/email/templates/partials/signature.hbs
@@ -1,4 +1,3 @@
-<p>With many thanks and best regards,
+<p>Kind regards,
   <br /> {{ signatureName }}
-  <br /> Hindawi
 </p>
\ No newline at end of file
diff --git a/packages/component-invite/src/routes/fragmentsInvitations/emails/emailCopy.js b/packages/component-invite/src/routes/fragmentsInvitations/emails/emailCopy.js
index 181da0098..4e53dc099 100644
--- a/packages/component-invite/src/routes/fragmentsInvitations/emails/emailCopy.js
+++ b/packages/component-invite/src/routes/fragmentsInvitations/emails/emailCopy.js
@@ -1,5 +1,7 @@
 const config = require('config')
 
+const journalName = config.get('journal.name')
+
 const getEmailCopy = ({
   emailType,
   titleText,
@@ -11,50 +13,48 @@ const getEmailCopy = ({
   let resend = false
   switch (emailType) {
     case 'reviewer-invitation':
-      upperContent = `${titleText}, has been submitted for possible publication in Hindawi. As the Academic Editor handling the manuscript, I would be delighted if you would agree to review it and let me know whether you feel it is suitable for publication.`
-      manuscriptText =
-        "The manuscript's abstract, and author information is below to help you decide. Once you have agreed to review, you will be able to download the full article PDF."
+      upperContent = `${titleText}, has been submitted to ${journalName} for consideration. As the Academic Editor handling the manuscript, I would be delighted if you would agree to review it and let me know whether you feel it is suitable for publication.`
+      manuscriptText = `If you are able to review the manuscript, I would be grateful if you could submit your
+        report by ${expectedDate}.<br/>
+        The manuscript's abstract and author information is below to help you decide. Once you have agreed to review, you will be able to download the full article PDF.`
       lowerContent = `If a potential conflict of interest exists between yourself and either the authors or
-      the subject of the manuscript, please decline to handle the manuscript. If a conflict
-      becomes apparent during the review process, please let me know at the earliest possible
-      opportunity. For more information about our conflicts of interest policies, please
-      see:
-      <a href="https://www.hindawi.com/ethics/#coi">https://www.hindawi.com/ethics/#coi</a>.<br/><br/>
-      If you are able to review the manuscript, I would be grateful if you could submit your
-      report by ${expectedDate}.`
+        the subject of the manuscript, please decline to handle the manuscript. If a conflict
+        becomes apparent during the review process, please let me know at the earliest possible
+        opportunity. For more information about our conflicts of interest policies, please
+        see:
+        <a href="https://www.hindawi.com/ethics/#coi">https://www.hindawi.com/ethics/#coi</a>.<br/><br/>`
       break
     case 'reviewer-resend-invitation':
       resend = true
-      upperContent = `On ${expectedDate} I sent you a request to review ${titleText}, submitted for possible publication in Hindawi.<br/><br/>
-        I would be grateful if you would agree to review it and let me know whether you feel
-        it is suitable for publication. If you are unable to review this manuscript then
-        please decline to review. More details are available by clicking the link.`
-      lowerContent = `I would like to thank you in advance for your help with the evaluation of this manuscript, since it would not be possible for us to run the journal without the help of our reviewers.<br/><br/>
+      upperContent = `On ${expectedDate} I invited you to review ${titleText}, submitted to ${journalName} for consideration.<br/><br/>
+        I would be grateful if you would agree to review the manuscript and let me know whether you feel
+        it is suitable for publication. If you are unable to review this manuscript please decline to review. More details are available by clicking the link below.`
+      lowerContent = `Thank you in advance for taking the time to consider this invitation, as it would not be possible for us to run the journal without the help of our reviewers.<br/><br/>
         I am looking forward to hearing from you.`
       break
     case 'reviewer-accepted':
       paragraph = `We are pleased to inform you that Dr. ${targetUserName} has agreed to review ${titleText}.<br/><br/>
-      You should receive the report by Dr. ${targetUserName} before ${expectedDate}. If you have any queries, or would like to send a reminder if no report has been submitted, then please visit the manuscript details page.`
+        You should receive the report before ${expectedDate}.<br/><br/>
+        If the review is delayed and you would like to send a reminder to Dr. ${targetUserName}, please visit the manuscript details page.`
       break
     case 'reviewer-declined':
       paragraph = `We regret to inform you that Dr. ${targetUserName} has declined to review ${titleText}.<br/><br/>
-      Please visit the manuscript details page to see if you need to invite any additional reviewers in order to reach a decision on the manuscript`
+        Please visit the manuscript details to invite additional reviewers in order to reach a decision on the manuscript. `
       break
     case 'reviewer-thank-you':
       paragraph = `Thank you for agreeing to review ${titleText}.<br/><br/>
-      You can view the full PDF file of the manuscript and post your review report using the following URL:`
+        You can view the full PDF file of the manuscript and post your review report using the following link.<br/>
+        You will be asked to log in before being able to complete your review.`
       break
     case 'reviewer-cancel-invitation':
-      paragraph = `You are no longer needed to review ${titleText}.<br/><br/>
-      If you have comments on this manuscript you believe the Editor should see, please email them to ${config.get(
-        'mailer.from',
-      )} as soon as possible.<br/><br/>
-        Thank you for your time and I hope you will consider reviewing for Hindawi again.`
+      paragraph = `We recently invited you to review ${titleText} for ${journalName}.<br/>
+        This is to confirm that we no longer require your review.<br/><br/>
+        If you have comments on the manuscript you believe I should see, please email them to ${config.get(
+          'journal.staffEmail',
+        )} as soon as possible.<br/><br/>
+        Thank you for your time and I hope you will consider reviewing for ${journalName} in the future.`
       hasLink = false
       break
-    case 'reviewer-new-account':
-      paragraph = `You have been invited to review ${titleText}. In order to respond to the invitation, you need to confirm your account.`
-      break
     default:
       throw new Error(`The ${emailType} email type is not defined.`)
   }
diff --git a/packages/component-invite/src/routes/fragmentsInvitations/emails/invitations.js b/packages/component-invite/src/routes/fragmentsInvitations/emails/invitations.js
index b66445efe..fdb2dd642 100644
--- a/packages/component-invite/src/routes/fragmentsInvitations/emails/invitations.js
+++ b/packages/component-invite/src/routes/fragmentsInvitations/emails/invitations.js
@@ -35,9 +35,6 @@ module.exports = {
     })
 
     const subjectBaseText = `${collection.customId}: Review`
-    const titleText = `The manuscript titled "${title}" by ${
-      submittingAuthor.firstName
-    } ${submittingAuthor.lastName}`
 
     let queryParams = {
       invitationId: invitation.id,
@@ -78,41 +75,50 @@ module.exports = {
       type: 'user',
       toUser: {
         email: invitedUser.email,
-        name: `${invitedUser.firstName} ${invitedUser.lastName}`,
+        name: `${invitedUser.lastName}`,
       },
       content: {
         title,
         abstract,
         agreeLink,
         declineLink,
-        subject: `${subjectBaseText} Requested`,
+        authorsList: authorsList.join(', '),
+        subject: `${subjectBaseText} invitation`,
         detailsLink: services.createUrl(baseUrl, detailsPath),
         signatureName: get(collection, 'handlingEditor.name', 'Hindawi'),
         unsubscribeLink: services.createUrl(baseUrl, unsubscribeSlug, {
           id: invitedUser.id,
         }),
-        authorsList: authorsList.join(', '),
       },
     })
 
     sendInvitedUserEmail({
       email,
-      titleText,
+      title,
       resend,
       timestamp,
+      authorName: `${submittingAuthor.firstName} ${submittingAuthor.lastName}`,
     })
   },
 }
 
 const sendInvitedUserEmail = async ({
   email,
-  titleText,
   resend,
+  title,
+  authorName,
   timestamp,
 }) => {
-  const emailType =
-    resend === true ? 'reviewer-resend-invitation' : 'reviewer-invitation'
-  const daysExpected = resend === true ? 0 : 14
+  let daysExpected = 14
+  let emailType = 'reviewer-invitation'
+  let titleText = `A manuscript titled "${title}" by ${authorName} et al.`
+
+  if (resend) {
+    emailType = 'reviewer-resend-invitation'
+    daysExpected = 0
+    email.content.subject = `${email.content.subject} reminder`
+    titleText = `the manuscript titled "${title}" by ${authorName}`
+  }
 
   const { html, text } = email.getBody({
     isReviewerInvitation: true,
diff --git a/packages/component-invite/src/routes/fragmentsInvitations/emails/notifications.js b/packages/component-invite/src/routes/fragmentsInvitations/emails/notifications.js
index 9eeb709b6..5ddd51df6 100644
--- a/packages/component-invite/src/routes/fragmentsInvitations/emails/notifications.js
+++ b/packages/component-invite/src/routes/fragmentsInvitations/emails/notifications.js
@@ -20,7 +20,6 @@ module.exports = {
     UserModel,
     emailType,
     collection,
-    isNewUser = false,
     isCanceled = false,
   }) {
     const fragmentHelper = new Fragment({ fragment })
@@ -38,9 +37,6 @@ module.exports = {
     const handlingEditor = get(collection, 'handlingEditor')
     const userHelper = new User({ UserModel })
     const eicName = await userHelper.getEiCName()
-    const subjectBaseText = isCanceled
-      ? `${collection.customId}: Reviewer `
-      : `${collection.customId}: Manuscript `
 
     const email = new Email({
       type: 'user',
@@ -61,7 +57,7 @@ module.exports = {
         reviewer,
         titleText,
         isCanceled,
-        subjectBaseText,
+        customId: collection.customId,
       })
     }
 
@@ -72,8 +68,8 @@ module.exports = {
         titleText,
         emailType,
         handlingEditor,
-        subjectBaseText,
-        targetUserName: `${reviewer.firstName} ${reviewer.lastName}`,
+        customId: collection.customId,
+        targetUserName: `${reviewer.lastName}`,
       })
     }
   },
@@ -83,18 +79,21 @@ const sendHandlingEditorEmail = ({
   email,
   eicName,
   baseUrl,
+  customId,
   titleText,
   emailType,
   handlingEditor,
   targetUserName,
-  subjectBaseText,
 }) => {
   email.toUser = {
     email: handlingEditor.email,
     name: handlingEditor.name,
   }
 
-  email.content.subject = `${subjectBaseText} Reviews`
+  email.content.subject =
+    emailType === 'reviewer-accepted'
+      ? `${customId}: A reviewer has agreed`
+      : `${customId}: A reviewer has declined`
   email.content.unsubscribeLink = services.createUrl(baseUrl, unsubscribeSlug, {
     id: handlingEditor.id,
   })
@@ -118,20 +117,21 @@ const sendReviewerEmail = async ({
   email,
   baseUrl,
   reviewer,
+  customId,
   titleText,
   isCanceled,
-  subjectBaseText,
 }) => {
   email.content.subject = isCanceled
-    ? `${subjectBaseText} Unassigned`
-    : `${subjectBaseText} Review`
+    ? `${customId}: Review no longer required`
+    : `${customId}: Thank you for agreeing to review`
+
   const emailType = isCanceled
     ? 'reviewer-cancel-invitation'
     : 'reviewer-thank-you'
 
   email.toUser = {
     email: reviewer.email,
-    name: `${reviewer.firstName} ${reviewer.lastName}`,
+    name: `${reviewer.lastName}`,
   }
 
   email.content.unsubscribeLink = services.createUrl(baseUrl, unsubscribeSlug, {
diff --git a/packages/xpub-faraday/config/default.js b/packages/xpub-faraday/config/default.js
index 768e93384..5b333bbdf 100644
--- a/packages/xpub-faraday/config/default.js
+++ b/packages/xpub-faraday/config/default.js
@@ -450,4 +450,8 @@ module.exports = {
     key: process.env.PUBLONS_KEY || '',
     reviewersUrl: 'https://api.clarivate.com/reviewer-connect/api/',
   },
+  journal: {
+    name: 'Bioinorganic Chemistry and Applications',
+    staffEmail: 'hindawi+staff@thinslices.com',
+  },
 }
-- 
GitLab