Skip to content
Snippets Groups Projects
Commit cec7344f authored by Sebastian Mihalache's avatar Sebastian Mihalache :hammer_pick:
Browse files

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

parents d7646c32 a2a0021a
No related branches found
No related tags found
1 merge request!115Hin 1038
......@@ -360,7 +360,73 @@ class Notification {
email.sendEmail({ html, text })
}
notifyReviewersWhenHEMakesRecommendation() {}
async notifyReviewersWhenHEMakesRecommendation() {
const {
eicName,
titleText,
recommendation,
fragmentHelper,
} = await this.getNotificationProperties()
const signatureName = get(this.collection, 'handlingEditor.name', eicName)
const subject =
recommendation === 'publish'
? 'A manuscript you reviewed has been accepted'
: 'A manuscript you reviewed has been rejected'
const acceptedReviewers = await fragmentHelper.getReviewers({
UserModel: this.UserModel,
type: 'accepted',
})
const acceptedReviewersEmailBody = getEmailCopy({
emailType: 'accepted-reviewers-after-recommendation',
titleText,
})
const pendingReviewers = await fragmentHelper.getReviewers({
UserModel: this.UserModel,
type: 'pending',
})
const pendingReviewersEmailBody = getEmailCopy({
emailType: 'pending-reviewers-after-recommendation',
titleText,
})
const buildSendEmailFunction = emailBodyProps => reviewer => {
const email = new Email({
type: 'user',
toUser: {
email: reviewer.email,
name: reviewer.lastName,
},
fromEmail: `${eicName} <${staffEmail}>`,
content: {
signatureName,
ctaText: 'MANUSCRIPT DETAILS',
subject: `${this.collection.customId}: ${subject}`,
unsubscribeLink: services.createUrl(this.baseUrl, unsubscribeSlug, {
id: reviewer.id,
token: reviewer.accessTokens.unsubscribe,
}),
ctaLink: services.createUrl(
this.baseUrl,
`/projects/${this.collection.id}/versions/${
this.fragment.id
}/details`,
),
signatureJournal: journalName,
},
})
const { html, text } = email.getNotificationBody({ emailBodyProps })
email.sendEmail({ html, text })
}
acceptedReviewers.forEach(
buildSendEmailFunction(acceptedReviewersEmailBody),
)
pendingReviewers.forEach(buildSendEmailFunction(pendingReviewersEmailBody))
}
notifyEiCWhenHEMakesRecommendation() {}
......
const uuid = require('uuid')
const { pick, get, set, has } = require('lodash')
const { pick, get, set, has, isEmpty } = require('lodash')
const config = require('config')
const { v4 } = require('uuid')
......@@ -135,6 +135,14 @@ module.exports = models => async (req, res) => {
await collection.save()
}
const notification = new Notification({
fragment,
collection,
newRecommendation,
UserModel: models.User,
baseUrl: services.getBaseUrl(req),
})
if (isEditorInChief) {
// notifications.sendNotificationsWhenEiCMakesDecision({
// hasEQA,
......@@ -145,13 +153,6 @@ module.exports = models => async (req, res) => {
// targetUserName: reqUser.lastName,
// baseUrl: services.getBaseUrl(req),
// })
const notification = new Notification({
fragment,
collection,
newRecommendation,
UserModel: models.User,
baseUrl: services.getBaseUrl(req),
})
if (
recommendation === 'publish' &&
......@@ -169,6 +170,12 @@ module.exports = models => async (req, res) => {
notification.notifyReviewersWhenEiCMakesDecision()
}
} else {
notification.notifySAWhenHERequestsRevision()
const hasPeerReview = !isEmpty(collection.handlingEditor)
if (hasPeerReview) {
notification.notifyReviewersWhenHEMakesRecommendation()
}
// notifications.sendNotificationsWhenHEMakesRecommendation({
// fragment,
// 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