Skip to content
Snippets Groups Projects
Commit f9ac84d5 authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

Merge branch 'develop' of gitlab.coko.foundation:xpub/xpub-faraday into develop

parents 0cf3ecb8 962a9f8a
No related branches found
No related tags found
1 merge request!13Sprint #14
...@@ -371,6 +371,31 @@ class Email { ...@@ -371,6 +371,31 @@ class Email {
}, },
}) })
} }
async setupNewVersionSubmittedEmail() {
const {
baseUrl,
UserModel,
collection,
parsedFragment: { id, title },
authors: { submittingAuthor: { firstName = '', lastName = '' } },
} = this
const userHelper = new User({ UserModel })
const eic = await userHelper.getEditorInChief()
mailService.sendNotificationEmail({
toEmail: eic.email,
emailType: 'new-version-submitted',
meta: {
baseUrl,
collection,
eicName: `${eic.firstName} ${eic.lastName}`,
fragment: { id, authorName: `${firstName} ${lastName}`, title },
handlingEditorName: collection.handlingEditor.name,
},
})
}
} }
const getSubject = recommendation => const getSubject = recommendation =>
......
...@@ -581,6 +581,26 @@ module.exports = { ...@@ -581,6 +581,26 @@ module.exports = {
replacements.signatureName replacements.signatureName
}` }`
break break
case 'new-version-submitted':
subject = `${meta.collection.customId}: Manuscript Update`
replacements.previewText = 'A manuscript has been updated'
replacements.intro = `Dear Dr. ${meta.handlingEditorName}`
replacements.paragraph = `A new version of the manuscript titled "${
meta.fragment.title
}" by ${meta.fragment.authorName} has been submitted.`
replacements.beforeAnchor =
'Previous reviewers have been automatically invited to review the manuscript again. Please visit the'
replacements.afterAnchor =
'to see the latest version and any other actions you may need to take.'
replacements.signatureName = meta.eicName
textBody = `${replacements.intro} ${replacements.paragraph} ${
replacements.beforeAnchor
} ${replacements.detailsUrl} ${replacements.afterAnchor} ${
replacements.signatureName
}`
break
default: default:
subject = 'Hindawi Notification!' subject = 'Hindawi Notification!'
break break
......
const { const {
Team, Team,
User, User,
Email,
services, services,
Fragment, Fragment,
Collection, Collection,
...@@ -103,6 +104,23 @@ module.exports = models => async (req, res) => { ...@@ -103,6 +104,23 @@ module.exports = models => async (req, res) => {
fragment.submitted = Date.now() fragment.submitted = Date.now()
fragment = await fragment.save() fragment = await fragment.save()
if (heRecommendation.recommendation === 'major') {
const fragmentHelper = new Fragment({ fragment })
const parsedFragment = await fragmentHelper.getFragmentData({
handlingEditor: collection.handlingEditor,
})
const authors = await fragmentHelper.getAuthorData({
UserModel: models.User,
})
const email = new Email({
authors,
collection,
parsedFragment,
UserModel: models.User,
baseUrl: services.getBaseUrl(req),
})
email.setupNewVersionSubmittedEmail()
}
return res.status(200).json(fragment) return res.status(200).json(fragment)
} catch (e) { } catch (e) {
......
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