diff --git a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js index b318595833c0efbf0f46f5b9ff37ad292b504677..b3f2e877a4aad364f605e362495d370193328932 100644 --- a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js +++ b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js @@ -1,5 +1,5 @@ const config = require('config') -const { chain, get } = require('lodash') +const { chain, get, isEmpty } = require('lodash') const { User, @@ -58,9 +58,13 @@ module.exports = { comments = eicComments } + + const hasPeerReview = (collection = {}) => + !isEmpty(collection.handlingEditor) + if ( (isEditorInChief || newRecommendation.recommendationType === 'review') && - collection.status !== 'rejected' + hasPeerReview(collection) ) { // the request came from either the Editor in Chief or a reviewer, so the HE needs to be notified sendHandlingEditorEmail({ @@ -81,17 +85,19 @@ module.exports = { newRecommendation.recommendationType !== 'review' && newRecommendation.recommendation !== 'return-to-handling-editor' ) { - sendAuthorsEmail({ - email, - baseUrl, - titleText, - parsedFragment, - fragmentAuthors, - isEditorInChief, - subjectBaseText, - newRecommendation, - }) - if (collection.status !== 'rejected') { + if (isEditorInChief || collection.status === 'revisionRequested') { + sendAuthorsEmail({ + email, + baseUrl, + titleText, + parsedFragment, + fragmentAuthors, + isEditorInChief, + subjectBaseText, + newRecommendation, + }) + } + if (hasPeerReview(collection)) { sendReviewersEmail({ email, baseUrl,