diff --git a/packages/component-invite/src/routes/collectionsInvitations/post.js b/packages/component-invite/src/routes/collectionsInvitations/post.js index 170277a769ec1610cb041938bb89dd3e00dddb54..932212103fd4a76707cf1498e0fbbb6ec4b9ed97 100644 --- a/packages/component-invite/src/routes/collectionsInvitations/post.js +++ b/packages/component-invite/src/routes/collectionsInvitations/post.js @@ -55,21 +55,49 @@ module.exports = models => async (req, res) => { if (role === 'handlingEditor') { await collectionHelper.addHandlingEditor(collection, user, invitation) } + const status = get(collection, 'status') + if (role === 'reviewer' && status === 'he-assigned') { + collection.status = 'reviewers-invited' + await collection.save() + } try { - let emailType - switch (role) { - case 'handlingEditor': - emailType = 'assign-handling-editor' - break - case 'reviewer': - emailType = 'invite-reviewer' - break - default: - return res.status(500).json({ - error: 'Something went wrong', - }) + if (role === 'handlingEditor') { + await mailService.setupAssignEmail( + user.email, + 'assign-handling-editor', + url, + ) + } else if (role === 'reviewer') { + const dashboardUrl = `${req.protocol}://${req.get('host')}` + const fragment = await models.Fragment.find(collection.fragments[0]) + const submittingAuthorData = collection.authors.find( + author => author.isSubmitting === true, + ) + const submittingAuthor = await models.User.find( + submittingAuthorData.userId, + ) + const authorsPromises = collection.authors.map(async author => { + const user = await models.User.find(author.userId) + return `${user.firstName} ${user.lastName}` + }) + const authors = await Promise.all(authorsPromises) + let { abstract, title } = fragment.metadata + title = title.replace(/<(.|\n)*?>/g, '') + abstract = abstract.replace(/<(.|\n)*?>/g, '') + await mailService.setupReviewerInvitationEmail( + user, + dashboardUrl, + collection, + abstract, + title, + submittingAuthor, + authors, + ) + } else { + return res.status(500).json({ + error: 'Something went wrong', + }) } - await mailService.setupAssignEmail(user.email, emailType, url) return res.status(200).json(user) } catch (e) { diff --git a/packages/component-mail-service/src/Mail.js b/packages/component-mail-service/src/Mail.js index 8ad93613f510483eceee3cd40d35506e832decd8..8d46d198ba6b4272d7d3551e25cd5c36d6a658f2 100644 --- a/packages/component-mail-service/src/Mail.js +++ b/packages/component-mail-service/src/Mail.js @@ -130,6 +130,54 @@ module.exports = { return Email.send(mailData) }, + setupReviewerInvitationEmail: async ( + invitedUser, + dashBoardUrl, + collection, + abstract, + title, + submittingAuthor, + authors, + token, + inviteUrl, + ) => { + const subject = `${collection.customId}: Review Requested` + let agreeUrl + const declineUrl = '' + if (invitedUser.isConfirmed) { + agreeUrl = '' + } else { + agreeUrl = `${inviteUrl}${resetPath}?${querystring.encode({ + email: invitedUser.email, + token, + })}` + } + + const replacements = { + name: `${invitedUser.firstName} ${invitedUser.lastName}`, + agreeUrl, + declineUrl, + dashBoardUrl, + title, + abstract, + editorName: collection.handlingEditor.name, + editorEmail: collection.handlingEditor.email, + submittingAuthorName: `${submittingAuthor.firstName} ${ + submittingAuthor.lastName + }`, + authors, + } + + const { htmlBody, textBody } = getEmailBody('invite-reviewer', replacements) + const mailData = { + from: config.get('mailer.from'), + to: invitedUser.email, + subject, + text: textBody, + html: htmlBody, + } + return Email.send(mailData) + }, } const getEmailBody = (emailType, replacements) => { diff --git a/packages/component-mail-service/src/templates/invite-reviewer.html b/packages/component-mail-service/src/templates/invite-reviewer.html index 90ad9a6b12304d999df41179eeb5702e3c3ac282..17402018dd7b3a4f7333bd9e76b43d4dfca99a2c 100644 --- a/packages/component-mail-service/src/templates/invite-reviewer.html +++ b/packages/component-mail-service/src/templates/invite-reviewer.html @@ -145,7 +145,7 @@ width="100%" style="display: none !important; mso-hide: all; visibility: hidden; opacity: 0; color: transparent; height: 0; width: 0;"> <tr> <td role="module-content"> - <p>invite reviewer</p> + <p>manuscript review request</p> </td> </tr> </table> @@ -160,52 +160,173 @@ </tr> </table> + <table class="module" role="module" data-type="text" border="0" cellpadding="0" cellspacing="0" width="100%" style="table-layout: fixed;"> + <tr> + <td style="padding:30px 23px 20px 23px;background-color:#ffffff;" height="100%" valign="top" bgcolor="#ffffff"> + <div> + <p data-pm-slice="1 1 []">Dear Dr. {{name}},</p> + + <p> </p> + + <p>A manuscript titled "{{title}}" by {{submittingAuthorName}}, has been submitted + for possible publication in Hindawi. As the Academic Editor handling the manuscript, + I would be delighted if you would agree to review it and let me know whether you + feel it is suitable for publication.</p> + </div> + + </td> + </tr> + </table> + + <table border="0" cellpadding="0" cellspacing="0" align="center" width="100%" role="module" data-type="columns" data-version="2" + style="background-color:#ffffff;padding:20px 0px 20px 0px;" bgcolor="#ffffff"> + <tr role='module-content'> + <td height="100%" valign="top"> + <!--[if (gte mso 9)|(IE)]> + <center> + <table cellpadding="0" cellspacing="0" border="0" width="100%" style="border-spacing:0;border-collapse:collapse;table-layout: fixed;" > + <tr> + <![endif]--> + + <!--[if (gte mso 9)|(IE)]> + <td width="300.000px" valign="top" style="padding: 0px 0px 0px 0px;border-collapse: collapse;" > + <![endif]--> + + <table width="300.000" style="width:300.000px;border-spacing:0;border-collapse:collapse;margin:0px 0px 0px 0px;" cellpadding="0" + cellspacing="0" align="left" border="0" bgcolor="#ffffff" class="column column-0 of-2 + empty"> + <tr> + <td style="padding:0px;margin:0px;border-spacing:0;"> + <table border="0" cellPadding="0" cellSpacing="0" class="module" data-role="module-button" data-type="button" role="module" + style="table-layout:fixed" width="100%"> + <tbody> + <tr> + <td align="center" bgcolor="" class="outer-td" style="padding:0px 0px 0px 0px"> + <table border="0" cellPadding="0" cellSpacing="0" class="button-css__deep-table___2OZyb wrapper-mobile" + style="text-align:center"> + <tbody> + <tr> + <td align="center" bgcolor="#0d78f2" class="inner-td" style="border-radius:6px;font-size:16px;text-align:center;background-color:inherit"> + <a href="{{agreeUrl}}" style="background-color:#0d78f2;border:1px solid #333333;border-color:#0d78f2;border-radius:0px;border-width:1px;color:#ffffff;display:inline-block;font-family:arial,helvetica,sans-serif;font-size:16px;font-weight:normal;letter-spacing:0px;line-height:16px;padding:12px 18px 12px 18px;text-align:center;text-decoration:none" + target="_blank">AGREE</a> + </td> + </tr> + </tbody> + </table> + </td> + </tr> + </tbody> + </table> + </td> + </tr> + </table> + + <!--[if (gte mso 9)|(IE)]> + </td> + <![endif]--> + <!--[if (gte mso 9)|(IE)]> + <td width="300.000px" valign="top" style="padding: 0px 0px 0px 0px;border-collapse: collapse;" > + <![endif]--> + + <table width="300.000" style="width:300.000px;border-spacing:0;border-collapse:collapse;margin:0px 0px 0px 0px;" cellpadding="0" + cellspacing="0" align="left" border="0" bgcolor="#ffffff" class="column column-1 of-2 + empty"> + <tr> + <td style="padding:0px;margin:0px;border-spacing:0;"> + <table border="0" cellPadding="0" cellSpacing="0" class="module" data-role="module-button" data-type="button" role="module" + style="table-layout:fixed" width="100%"> + <tbody> + <tr> + <td align="center" bgcolor="" class="outer-td" style="padding:0px 0px 0px 0px"> + <table border="0" cellPadding="0" cellSpacing="0" class="button-css__deep-table___2OZyb wrapper-mobile" + style="text-align:center"> + <tbody> + <tr> + <td align="center" bgcolor="#e4dfdf" class="inner-td" style="border-radius:6px;font-size:16px;text-align:center;background-color:inherit"> + <a href="{{declineUrl}}" style="background-color:#e4dfdf;border:1px solid #333333;border-color:#E4DFDF;border-radius:0px;border-width:1px;color:#302e2e;display:inline-block;font-family:arial,helvetica,sans-serif;font-size:16px;font-weight:normal;letter-spacing:0px;line-height:16px;padding:12px 18px 12px 18px;text-align:center;text-decoration:none" + target="_blank">DECLINE</a> + </td> + </tr> + </tbody> + </table> + </td> + </tr> + </tbody> + </table> + </td> + </tr> + </table> + + <!--[if (gte mso 9)|(IE)]> + </td> + <![endif]--> + <!--[if (gte mso 9)|(IE)]> + <tr> + </table> + </center> + <![endif]--> + </td> + </tr> + </table> + <table class="module" role="module" data-type="text" border="0" cellpadding="0" cellspacing="0" width="100%" style="table-layout: fixed;"> <tr> <td style="padding:30px 23px 0px 23px;background-color:#ffffff;" height="100%" valign="top" bgcolor="#ffffff"> - <h1 style="text-align: center;">You have been requested to review a manuscript.</h1> - <div style="text-align: center;">Please click on the link below to access your dashboard.</div> + <p data-pm-slice="1 1 []"> + <a href="{{dashboardUrl}}">See more information</a> + </p> - <div style="text-align: center;"> </div> + <p data-pm-slice="1 1 []"> </p> + + <p data-pm-slice="1 1 []">The manuscript’s abstract, and author information is below to help you decide. + Once you have agreed to review, you will be able to download the full article PDF.</p> + + <p> </p> + + <p>{{title}} + <br /> {{authors}} + </p> + + <p> + <br /> {{abstract}} + </p> + + <p> </p> + + <p>If a potential conflict of interest exists between yourself and either the authors or + the subject of the manuscript, please decline to handle the manuscript. If a conflict + becomes apparent during the review process, please let me know at the earliest possible + opportunity. For more information about our conflicts of interest policies, please + see: + <a href="https://www.hindawi.com/ethics/#coi.">https://www.hindawi.com/ethics/#coi.</a> + </p> + + <p> </p> + + <p>With many thanks and best regards, + <br /> {{editorName}} + <br /> {{editorEmail}} + </p> <div style="text-align: center;"> </div> </td> </tr> </table> - <table border="0" cellPadding="0" cellSpacing="0" class="module" data-role="module-button" data-type="button" role="module" - style="table-layout:fixed" width="100%"> - <tbody> - <tr> - <td align="center" bgcolor="#FFFFFF" class="outer-td" style="padding:0px 0px 30px 0px;background-color:#FFFFFF"> - <table border="0" cellPadding="0" cellSpacing="0" class="button-css__deep-table___2OZyb wrapper-mobile" - style="text-align:center"> - <tbody> - <tr> - <td align="center" bgcolor="#0d78f2" class="inner-td" style="border-radius:6px;font-size:16px;text-align:center;background-color:inherit"> - <a href="{{ url }}" style="background-color:#0d78f2;border:1px solid #333333;border-color:#0d78f2;border-radius:0px;border-width:1px;color:#ffffff;display:inline-block;font-family:arial,helvetica,sans-serif;font-size:16px;font-weight:normal;letter-spacing:0px;line-height:16px;padding:12px 18px 12px 18px;text-align:center;text-decoration:none" - target="_blank">VIEW DASHBOARD</a> - </td> - </tr> - </tbody> - </table> - </td> - </tr> - </tbody> - </table> - <div data-role="module-unsubscribe" class="module unsubscribe-css__unsubscribe___2CDlR" role="module" - data-type="unsubscribe" style="color:#444444;font-size:12px;line-height:20px;padding:16px 16px 16px 16px;text-align:center"> + <div data-role="module-unsubscribe" class="module unsubscribe-css__unsubscribe___2CDlR" role="module" data-type="unsubscribe" + style="color:#444444;font-size:12px;line-height:20px;padding:16px 16px 16px 16px;text-align:center"> <div class="Unsubscribe--addressLine"> - <p class="Unsubscribe--senderName" style="font-family:Arial, Helvetica, sans-serif;font-size:12px;line-height:20px">Hindawi Publishing Corporation</p> - <p style="font-family:Arial, Helvetica, sans-serif;font-size:12px;line-height:20px"> + <p class="Unsubscribe--senderName" style="font-family:Arial,Helvetica, sans-serif;font-size:12px;line-height:20px">[Sender_Name]</p> + <p style="font-family:Arial,Helvetica, sans-serif;font-size:12px;line-height:20px"> <span class="Unsubscribe--senderAddress">315 Madison Ave, Third Floor, Suite 3070</span>, <span class="Unsubscribe--senderCity">NEW YORK</span>, <span class="Unsubscribe--senderState">NY</span> <span class="Unsubscribe--senderZip">10017</span> </p> </div> - <p style="font-family:Arial, Helvetica, sans-serif;font-size:12px;line-height:20px"> - <a class="Unsubscribe--unsubscribeLink" href="[Unsubscribe]">Unsubscribe</a> + <p style="font-family:Arial,Helvetica, sans-serif;font-size:12px;line-height:20px"> + <a class="Unsubscribe--unsubscribeLink" href="[Unsubscribe]">Unsubscribe</a> - + <a class="Unsubscribe--unsubscribePreferences" href="[Unsubscribe_Preferences]">Unsubscribe Preferences</a> </p> </div> </td> diff --git a/packages/component-mail-service/src/templates/invite-reviewer.txt b/packages/component-mail-service/src/templates/invite-reviewer.txt index 90d999018f7fa366d4d23b80288aa2e6f0ab39f5..506e313f96abe4fb0fe9b9cf0f11c10e4b4eaace 100644 --- a/packages/component-mail-service/src/templates/invite-reviewer.txt +++ b/packages/component-mail-service/src/templates/invite-reviewer.txt @@ -1,6 +1,31 @@ -You have been requested to review a manuscript. -Please click on the link below to access your dashboard -{{ url }} VIEW DASHBOARD -Hindawi Publishing Corporation -315 Madison Ave, Third Floor, Suite 307 -New York, NY 10017 \ No newline at end of file + +Dear Dr. {{name}}, + +A manuscript titled {{title}}" by {{submittingAuthorName}}, has been submitted +for possible publication in Hindawi. As the Academic Editor handling the manuscript, +I would be delighted if you would agree to review it and let me know whether you + +{{agreeUrl}} +AGREE + +{{declineUrl}} +DECLINE + +{{dashboardUrl}} See more information + +The manuscript's abstract, and author information is below to help you decide. +Once you have agreed to review, you will be able to download the full article PDF. +{{title}} +{{authors}} +{{abstract}} + +If a potential conflict of interest exists between yourself and either the authors or +the subject of the manuscript, please decline to handle the manuscript. If a conflict +becomes apparent during the review process, please let me know at the earliest possible +opportunity. For more information about our conflicts of interest policies, please +see: +https://www.hindawi.com/ethics/#coi + +With many thanks and best regards, +{{editorName}} +{{editorEmail}} \ No newline at end of file