Skip to content
Snippets Groups Projects
Commit 5ad36231 authored by Mihail Hagiu's avatar Mihail Hagiu
Browse files

fix(ReviewerReminders): Changed logic

parent 78cd75cd
No related branches found
No related tags found
3 merge requests!233S26 updates,!230S26 Updates,!228feat(AutomaticReminder): ReviewerResendInvitationEmail
This commit is part of merge request !228. Comments created here will be created in the context of that merge request.
...@@ -41,6 +41,7 @@ const getEmailCopy = ({ ...@@ -41,6 +41,7 @@ const getEmailCopy = ({
We look forward to hearing from you.` We look forward to hearing from you.`
break break
case 'reviewer-resend-invitation-second-reminder': case 'reviewer-resend-invitation-second-reminder':
case 'reviewer-resend-invitation-third-reminder':
resend = true resend = true
upperContent = `We sent you a request to review ${titleText}; however we have not yet received your decision. upperContent = `We sent you a request to review ${titleText}; however we have not yet received your decision.
We would appreciate it if you could visit the following link to let us know whether or not you will be able to review this manuscript:` We would appreciate it if you could visit the following link to let us know whether or not you will be able to review this manuscript:`
......
const config = require('config') const config = require('config')
const { get } = require('lodash') const { get, forOwn } = require('lodash')
const Email = require('@pubsweet/component-email-templating') const Email = require('@pubsweet/component-email-templating')
const unsubscribeSlug = config.get('unsubscribe.url') const unsubscribeSlug = config.get('unsubscribe.url')
...@@ -13,11 +13,7 @@ const { getEmailCopy } = require('./emailCopy') ...@@ -13,11 +13,7 @@ const { getEmailCopy } = require('./emailCopy')
const { scheduleReminderJob } = require('../jobs/reminders') const { scheduleReminderJob } = require('../jobs/reminders')
const { scheduleRemovalJob } = require('../jobs/removal') const { scheduleRemovalJob } = require('../jobs/removal')
const reminderList = [ const daysList = config.get('reminders.reviewer.days')
config.get('reminders.reviewer.first'),
config.get('reminders.reviewer.second'),
config.get('reminders.reviewer.third'),
]
const timeUnit = config.get('reminders.reviewer.timeUnit') const timeUnit = config.get('reminders.reviewer.timeUnit')
const removalDays = config.get('reminders.reviewer.remove') const removalDays = config.get('reminders.reviewer.remove')
const daysExpected = config.get('daysExpectedForReview') const daysExpected = config.get('daysExpectedForReview')
...@@ -121,11 +117,12 @@ module.exports = { ...@@ -121,11 +117,12 @@ module.exports = {
await email.sendEmail() await email.sendEmail()
reminderList.forEach(reminder => forOwn(daysList, (day, order) =>
scheduleReminderJob({ scheduleReminderJob({
day,
order,
email, email,
timeUnit, timeUnit,
reminder,
userId: invitedUser.id, userId: invitedUser.id,
invitationId: invitation.id, invitationId: invitation.id,
subject: `${subjectBaseText} reminder`, subject: `${subjectBaseText} reminder`,
......
...@@ -6,25 +6,25 @@ const { getEmailCopy } = require('../emails/emailCopy') ...@@ -6,25 +6,25 @@ const { getEmailCopy } = require('../emails/emailCopy')
const Email = require('@pubsweet/component-email-templating') const Email = require('@pubsweet/component-email-templating')
const scheduleReminderJob = async ({ const scheduleReminderJob = async ({
day,
email, email,
order,
userId, userId,
subject, subject,
timeUnit, timeUnit,
reminder, daysList,
titleText, titleText,
invitationId, invitationId,
expectedDate, expectedDate,
}) => { }) => {
const { days, emailType } = reminder
const executionDate = moment() const executionDate = moment()
.add(days, timeUnit) .add(day, timeUnit)
.toISOString() .toISOString()
const queue = `reminders-${userId}-${invitationId}` const queue = `reminders-${userId}-${invitationId}`
const { paragraph, ...bodyProps } = getEmailCopy({ const { paragraph, ...bodyProps } = getEmailCopy({
emailType, emailType: `reviewer-resend-invitation-${order}-reminder`,
titleText, titleText,
expectedDate, expectedDate,
}) })
...@@ -33,7 +33,7 @@ const scheduleReminderJob = async ({ ...@@ -33,7 +33,7 @@ const scheduleReminderJob = async ({
email.content.subject = subject email.content.subject = subject
const params = { const params = {
days, day,
timeUnit, timeUnit,
executionDate, executionDate,
emailProps: cloneDeep(email), emailProps: cloneDeep(email),
......
...@@ -149,22 +149,12 @@ module.exports = { ...@@ -149,22 +149,12 @@ module.exports = {
), ),
reminders: { reminders: {
reviewer: { reviewer: {
first: { days: {
days: process.env.REMINDER_REVIEWER_FIRST || 4, first: process.env.REMINDER_REVIEWER_FIRST || 4,
emailType: 'reviewer-resend-invitation-first', second: process.env.REMINDER_REVIEWER_SECOND || 7,
}, third: process.env.REMINDER_REVIEWER_THIRD || 14,
second: {
days: process.env.REMINDER_REVIEWER_SECOND || 7,
emailType: 'reviewer-resend-invitation-second',
},
third: {
days: process.env.REMINDER_REVIEWER_THIRD || 14,
emailType: 'reviewer-resend-invitation-second',
},
remove: {
days: process.env.REMINDER_REMOVE_REVIEWER || 21,
emailType: '',
}, },
remove: process.env.REMINDER_REMOVE_REVIEWER || 21,
timeUnit: process.env.REMINDER_REVIEWER_TIME_UNIT || 'days', timeUnit: process.env.REMINDER_REVIEWER_TIME_UNIT || 'days',
}, },
}, },
......
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