diff --git a/packages/component-helper-service/src/services/Email.js b/packages/component-helper-service/src/services/Email.js index c375875f8157884196f93b2b4e5abf75cd730c03..49fb18189f0b322fe38ad0ca97de5af1203bdbb5 100644 --- a/packages/component-helper-service/src/services/Email.js +++ b/packages/component-helper-service/src/services/Email.js @@ -140,7 +140,7 @@ class Email { baseUrl, emailType, toEmail: toAuthor.email, - handlingEditorName: collection.handlingEditor.name, + handlingEditorName: get(collection, 'handlingEditor.name'), meta: { collection, authorNoteText, @@ -157,6 +157,7 @@ class Email { async setupHandlingEditorEmail({ publish = false, + returnWithComments = false, reviewSubmitted = false, reviewerName = '', }) { @@ -164,16 +165,17 @@ class Email { baseUrl, UserModel, collection, - parsedFragment: { title, id }, + parsedFragment: { eicComments = '', title, id }, authors: { submittingAuthor: { firstName = '', lastName = '' } }, } = this const userHelper = new User({ UserModel }) const eic = await userHelper.getEditorInChief() - const toEmail = collection.handlingEditor.email + const toEmail = get(collection, 'handlingEditor.email') let emailType = publish ? 'he-manuscript-published' : 'he-manuscript-rejected' if (reviewSubmitted) emailType = 'review-submitted' + if (returnWithComments) emailType = 'he-manuscript-return-with-comments' mailService.sendNotificationEmail({ toEmail, baseUrl, @@ -181,8 +183,9 @@ class Email { meta: { collection, reviewerName, + eicComments, eicName: `${eic.firstName} ${eic.lastName}`, - handlingEditorName: collection.handlingEditor.name, + handlingEditorName: get(collection, 'handlingEditor.name') || '', emailSubject: `${collection.customId}: Manuscript Decision`, fragment: { id, @@ -241,7 +244,7 @@ class Email { collection, fragment: { id }, eicName: `${eic.firstName} ${eic.lastName}`, - handlingEditorName: collection.handlingEditor.name, + handlingEditorName: get(collection, 'handlingEditor.name'), }, }) } diff --git a/packages/component-helper-service/src/services/Fragment.js b/packages/component-helper-service/src/services/Fragment.js index 80b38b4b6caafc3a5f96ac36253fa9f44cfd239b..64a0cb191ba86271ba9a555b8590315e68f1ae99 100644 --- a/packages/component-helper-service/src/services/Fragment.js +++ b/packages/component-helper-service/src/services/Fragment.js @@ -60,7 +60,7 @@ class Fragment { } getReviewerInvitations({ agree = true }) { - const { fragment: { invitations } } = this + const { fragment: { invitations = [] } } = this return agree ? invitations.filter( inv => diff --git a/packages/component-mail-service/src/Mail.js b/packages/component-mail-service/src/Mail.js index 69ffa1481fd9b4562d66d646f8b553654aff8c50..d40d99d1f2803362450ef95ec51552948ce6e791 100644 --- a/packages/component-mail-service/src/Mail.js +++ b/packages/component-mail-service/src/Mail.js @@ -522,6 +522,25 @@ module.exports = { replacements.signatureName }` break + case 'he-manuscript-return-with-comments': + subject = meta.emailSubject + replacements.hasLink = false + replacements.previewText = + 'a manuscript has been returned with comments' + replacements.intro = `Dear Dr. ${meta.handlingEditorName}` + + replacements.paragraph = `Thank you for your recommendation for the manuscript titled "${ + meta.fragment.title + }" by ${ + meta.fragment.authorName + } based on the reviews you received.<br/><br/> + ${meta.eicComments}<br/><br/>` + delete replacements.detailsUrl + replacements.signatureName = meta.eicName + textBody = `${replacements.intro} ${replacements.paragraph} ${ + replacements.signatureName + }` + break case 'submitting-reviewers-after-decision': subject = meta.emailSubject replacements.hasLink = false diff --git a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js index 68a3e796fc609f546537e99901559e80fc465e3c..6a7d8cf884bf69593ffdd2467a559c48c95aed40 100644 --- a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js +++ b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js @@ -1,4 +1,5 @@ const uuid = require('uuid') +const { chain } = require('lodash') const { Email, services, @@ -71,9 +72,18 @@ module.exports = models => async (req, res) => { }) const FragmentModel = models.Fragment if (reqUser.editorInChief || reqUser.admin) { - if (recommendation === 'return-to-handling-editor') + if (recommendation === 'return-to-handling-editor') { collectionHelper.updateStatus({ newStatus: 'reviewCompleted' }) - else { + const eicComments = chain(newRecommendation) + .get('comments') + .find(comm => !comm.public) + .get('content') + .value() + email.parsedFragment.eicComments = eicComments + email.setupHandlingEditorEmail({ + returnWithComments: true, + }) + } else { collectionHelper.updateFinalStatusByRecommendation({ recommendation, })