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

feat(HEEmailHERemoved): Created email template and code for sending it

parent edd99e13
No related branches found
No related tags found
3 merge requests!196S25 - EiC submit revision,!189S25,!172feat(HEEmailHERemoved): Created email template and code for sending it
...@@ -124,6 +124,13 @@ module.exports = models => async (req, res) => { ...@@ -124,6 +124,13 @@ module.exports = models => async (req, res) => {
fragment.revision && delete fragment.revision fragment.revision && delete fragment.revision
await fragment.save() await fragment.save()
notifications.notifyInvitedHEWhenRemoved({
models,
collection,
invitedHE: user,
baseUrl: services.getBaseUrl(req),
})
if (shouldAuthorBeNotified) { if (shouldAuthorBeNotified) {
notifications.notifyAuthorWhenHERemoved({ notifications.notifyAuthorWhenHERemoved({
models, models,
......
...@@ -43,6 +43,14 @@ const getEmailCopy = ({ emailType, titleText, targetUserName, comments }) => { ...@@ -43,6 +43,14 @@ const getEmailCopy = ({ emailType, titleText, targetUserName, comments }) => {
If you have questions please email them to ${staffEmail}<br/><br/>. If you have questions please email them to ${staffEmail}<br/><br/>.
Thank you for your submission to ${journalName}.` Thank you for your submission to ${journalName}.`
break break
case 'he-he-removed':
hasIntro = true
hasLink = false
hasSignature = true
paragraph = `The Editor in Chief removed you from the manuscript "${titleText}".<br/><br/>
If you have any questions regarding this action, please let us know at ${staffEmail}.<br/><br/>
Thank you for reviewing ${journalName}.`
break
default: default:
throw new Error(`The ${emailType} email type is not defined.`) throw new Error(`The ${emailType} email type is not defined.`)
} }
......
...@@ -85,9 +85,6 @@ module.exports = { ...@@ -85,9 +85,6 @@ module.exports = {
const { submittingAuthor } = await fragmentHelper.getAuthorData({ const { submittingAuthor } = await fragmentHelper.getAuthorData({
UserModel, UserModel,
}) })
const submittingAuthorName = `${submittingAuthor.firstName} ${
submittingAuthor.lastName
}`
const userHelper = new User({ UserModel }) const userHelper = new User({ UserModel })
const eics = await userHelper.getEditorsInChief() const eics = await userHelper.getEditorsInChief()
...@@ -97,7 +94,6 @@ module.exports = { ...@@ -97,7 +94,6 @@ module.exports = {
const { paragraph, ...bodyProps } = getEmailCopy({ const { paragraph, ...bodyProps } = getEmailCopy({
titleText, titleText,
targetUserName: submittingAuthorName,
emailType: 'author-he-removed', emailType: 'author-he-removed',
}) })
...@@ -106,7 +102,7 @@ module.exports = { ...@@ -106,7 +102,7 @@ module.exports = {
fromEmail: `${eicName} <${staffEmail}>`, fromEmail: `${eicName} <${staffEmail}>`,
toUser: { toUser: {
email: submittingAuthor.email, email: submittingAuthor.email,
name: submittingAuthorName, name: `${submittingAuthor.lastName}`,
}, },
content: { content: {
subject: `${customId}: Your manuscript's editor was changed`, subject: `${customId}: Your manuscript's editor was changed`,
...@@ -123,6 +119,50 @@ module.exports = { ...@@ -123,6 +119,50 @@ module.exports = {
return email.sendEmail() return email.sendEmail()
}, },
notifyInvitedHEWhenRemoved: async ({
baseUrl,
invitedHE,
collection,
models: { User: UserModel, Fragment: FragmentModel },
}) => {
const fragmentId = last(collection.fragments)
const fragment = await FragmentModel.find(fragmentId)
const fragmentHelper = new Fragment({ fragment })
const { title: titleText } = await fragmentHelper.getFragmentData()
const userHelper = new User({ UserModel })
const eics = await userHelper.getEditorsInChief()
const eic = eics[0]
const eicName = `${eic.firstName} ${eic.lastName}`
const { customId } = collection
const { paragraph, ...bodyProps } = getEmailCopy({
titleText,
emailType: 'he-he-removed',
})
const email = new Email({
type: 'user',
fromEmail: `${eicName} <${staffEmail}>`,
toUser: {
email: invitedHE.email,
name: `${invitedHE.lastName}`,
},
content: {
subject: `${customId}: The editor in chief removed you from ${titleText}`,
paragraph,
signatureName: eicName,
signatureJournal: journalName,
unsubscribeLink: services.createUrl(baseUrl, unsubscribeSlug, {
id: invitedHE.id,
token: invitedHE.accessTokens.unsubscribe,
}),
},
bodyProps,
})
return email.sendEmail()
},
sendEiCEmail: async ({ sendEiCEmail: async ({
reason, reason,
baseUrl, baseUrl,
......
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