Skip to content
Snippets Groups Projects
Commit 94340b96 authored by Sebastian Mihalache's avatar Sebastian Mihalache
Browse files

feat(component-manuscript-manager): send emails on manuscript published

parent c6145e06
No related branches found
No related tags found
1 merge request!10Sprint #12
......@@ -468,6 +468,24 @@ module.exports = {
replacements.signatureName
}`
break
case 'author-manuscript-published':
subject = `${meta.collection.customId}: Manuscript Decision`
replacements.previewText = 'a manuscript has been published'
replacements.intro = `Dear Dr. ${meta.fragment.authorName}`
replacements.paragraph = `I am delighted to inform you that manuscript titled "${
meta.fragment.title
}" by ${
meta.fragment.submittingAuthorName
} has passed through the review process and will be published in Hindawi.<br/><br/>
${meta.authorNoteText}<br/><br/>
Thanks again for choosing to publish with us.`
replacements.hasLink = false
delete replacements.detailsUrl
replacements.signatureName = meta.handlingEditorName
textBody = `${replacements.intro} ${replacements.paragraph} ${
replacements.signatureName
}`
break
case 'he-manuscript-rejected':
subject = meta.emailSubject
replacements.hasLink = false
......@@ -486,6 +504,24 @@ module.exports = {
replacements.signatureName
}`
break
case 'he-manuscript-published':
subject = meta.emailSubject
replacements.hasLink = false
replacements.previewText = 'a manuscript has been published'
replacements.intro = `Dear Dr. ${meta.handlingEditorName}`
replacements.paragraph = `Thank you for your recommendation to publish the manuscript titled "${
meta.fragment.title
}" by ${
meta.fragment.authorName
} based on the reviews you received.<br/><br/>
I can confirm this article will now go through to publication.`
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
......@@ -496,7 +532,9 @@ module.exports = {
meta.fragment.title
}" by ${
meta.fragment.authorName
}. After taking into account the reviews and the recommendation of the Handling Editor, I can confirm this article has now been rejected.<br/><br/>
}. After taking into account the reviews and the recommendation of the Handling Editor, I can confirm this article ${
meta.emailText
}.<br/><br/>
If you have any queries about this decision, then please email them to Hindawi as soon as possible.`
delete replacements.detailsUrl
replacements.signatureName = meta.editorName
......
......@@ -64,9 +64,14 @@ const setupReviewersEmail = async ({
const subject = isSubmitted
? `${collection.customId}: Manuscript Decision`
: `${collection.customId}: Manuscript ${getSubject(recommendation)}`
const emailType = isSubmitted
? 'submitting-reviewers-after-decision'
: 'agreed-reviewers-after-recommendation'
let emailType = 'agreed-reviewers-after-recommendation'
let emailText
if (isSubmitted) {
emailType = 'submitting-reviewers-after-decision'
emailText = 'has now been rejected'
if (recommendation === 'publish') emailText = 'will now be published'
}
const eic = await getEditorInChief(UserModel)
const editorName = isSubmitted
? `${eic.firstName} ${eic.lastName}`
......@@ -80,6 +85,7 @@ const setupReviewersEmail = async ({
editorName,
emailSubject: subject,
reviewerName: `${user.firstName} ${user.lastName}`,
emailText,
},
}),
)
......@@ -174,14 +180,16 @@ const setupAuthorsEmailData = async ({
collection,
comments,
requestToRevision = false,
publish = false,
}) => {
const authorNote = comments.find(comm => comm.public === true)
const content = get(authorNote, 'content')
const authorNoteText =
content !== undefined ? `Reason & Details: "${content}"` : ''
const emailType = requestToRevision
let emailType = requestToRevision
? 'author-request-to-revision'
: 'author-manuscript-rejected'
if (publish) emailType = 'author-manuscript-published'
let toAuthors = []
if (emailType === 'author-request-to-revision') {
toAuthors.push({
......@@ -216,16 +224,20 @@ const setupAuthorsEmailData = async ({
})
}
const setupManuscriptRejectedEmailForHe = async ({
const setupManuscriptDecisionEmailForHe = async ({
UserModel,
fragment: { title, submittingAuthor },
collection: { customId, handlingEditor },
publish = false,
}) => {
const eic = await getEditorInChief(UserModel)
const toEmail = handlingEditor.email
const emailType = publish
? 'he-manuscript-published'
: 'he-manuscript-rejected'
await mailService.sendNotificationEmail({
toEmail,
emailType: 'he-manuscript-rejected',
emailType,
meta: {
emailSubject: `${customId}: Manuscript Decision`,
fragment: {
......@@ -259,5 +271,5 @@ module.exports = {
setupEiCRecommendationEmailData,
setupAuthorsEmailData,
setupNoResponseReviewersEmailData,
setupManuscriptRejectedEmailForHe,
setupManuscriptDecisionEmailForHe,
}
......@@ -69,12 +69,11 @@ module.exports = models => async (req, res) => {
if (reqUser.editorInChief || reqUser.admin) {
if (recommendation === 'return-to-handling-editor')
await collectionHelper.updateStatus(collection, 'reviewCompleted')
else
else {
await collectionHelper.updateFinalStatusByRecommendation(
collection,
recommendation,
)
if (recommendation === 'reject') {
await userHelper.setupAuthorsEmailData({
baseUrl,
UserModel,
......@@ -82,15 +81,18 @@ module.exports = models => async (req, res) => {
fragment: { title, submittingAuthor },
comments: get(heRecommendation, 'comments'),
requestToRevision: false,
publish: recommendation === 'publish',
})
await userHelper.setupManuscriptRejectedEmailForHe({
await userHelper.setupManuscriptDecisionEmailForHe({
UserModel,
fragment: { title, submittingAuthor },
collection: {
customId: collection.customId,
handlingEditor: collection.handlingEditor,
},
publish: recommendation === 'publish',
})
await userHelper.setupReviewersEmail({
UserModel,
collection,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment