diff --git a/packages/component-helper-service/src/services/User.js b/packages/component-helper-service/src/services/User.js index 39d03896853ea00f5bb81425bdda1bb551f7af7f..cc5578b4558c3bdde3c870726e44a0e65d90fe3c 100644 --- a/packages/component-helper-service/src/services/User.js +++ b/packages/component-helper-service/src/services/User.js @@ -72,7 +72,9 @@ class User { async getEiCName() { const editorsInChief = await this.getEditorsInChief() - const { firstName, lastName } = editorsInChief[0] + const firstName = get(editorsInChief, '0.firstName', 'Editor') + const lastName = get(editorsInChief, '0.lastName', 'in Chief') + return `${firstName} ${lastName}` } } 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 b3f2e877a4aad364f605e362495d370193328932..df48f227da027af37cf066e772425017b845a1f2 100644 --- a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js +++ b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js @@ -33,12 +33,15 @@ module.exports = { fragmentAuthors.submittingAuthor.firstName } ${fragmentAuthors.submittingAuthor.lastName}` + const userHelper = new User({ UserModel }) + const eicName = await userHelper.getEiCName() + const email = new Email({ type: 'user', content: { unsubscribeLink: baseUrl, ctaText: 'MANUSCRIPT DETAILS', - signatureName: get(collection, 'handlingEditor.name', 'N/A'), + signatureName: eicName, ctaLink: services.createUrl( baseUrl, `/projects/${collection.id}/versions/${fragment.id}/details`, @@ -46,8 +49,6 @@ module.exports = { }, }) - const userHelper = new User({ UserModel }) - let comments if (isEditorInChief) { const eicComments = chain(newRecommendation) @@ -95,6 +96,7 @@ module.exports = { isEditorInChief, subjectBaseText, newRecommendation, + handlingEditorName: get(collection, 'handlingEditor.name', eicName), }) } if (hasPeerReview(collection)) { @@ -163,7 +165,7 @@ const sendHandlingEditorEmail = ({ email.content.unsubscribeLink = services.createUrl(baseUrl, unsubscribeSlug, { id: handlingEditor.id, }) - email.content.signatureName = eicName + const { html, text } = email.getBody({ body: getEmailCopy({ emailType, @@ -183,6 +185,7 @@ const sendAuthorsEmail = async ({ subjectBaseText, fragmentAuthors, newRecommendation, + handlingEditorName, parsedFragment: { heRecommendation }, }) => { let emailType, authors, comments @@ -216,7 +219,10 @@ const sendAuthorsEmail = async ({ })) } else { emailType = 'author-request-to-revision' + email.content.subject = `${subjectBaseText} Recommendation` + email.content.signatureName = handlingEditorName + const authorNote = newRecommendation.comments.find(comm => comm.public) const content = get(authorNote, 'content') const authorNoteText = content ? `Reason & Details: "${content}"` : '' @@ -285,7 +291,6 @@ const sendReviewersEmail = async ({ titleText, }), })) - email.content.signatureName = eicName } else { email.content.signatureName = handlingEditorName email.content.subject = `${subjectBaseText} ${getSubjectByRecommendation(