Skip to content
Snippets Groups Projects
Commit 1a8fe4c9 authored by Sinzeanu Demetriad's avatar Sinzeanu Demetriad
Browse files

docs(delete/emailCopy/notifications): pull from develop

parents 04bee2c1 edd99e13
No related branches found
No related tags found
3 merge requests!222Sprint #26,!217Sprint #26,!191Hin 1116 documentation
......@@ -114,19 +114,32 @@ module.exports = models => async (req, res) => {
await deleteFilesS3({ fileKeys, s3Config })
}
let shouldAuthorBeNotified
if (fragment.invitations.length > 0) {
shouldAuthorBeNotified = true
}
fragment.invitations = []
fragment.recommendations = []
fragment.revision && delete fragment.revision
fragment.save()
}
await fragment.save()
notifications.sendInvitedHEEmail({
models,
collection,
invitedHE: user,
isCanceled: true,
baseUrl: services.getBaseUrl(req),
})
if (shouldAuthorBeNotified) {
notifications.notifyAuthorWhenHERemoved({
models,
collection,
baseUrl: services.getBaseUrl(req),
})
}
} else {
notifications.sendInvitedHEEmail({
models,
collection,
invitedHE: user,
isCanceled: true,
baseUrl: services.getBaseUrl(req),
})
}
return res.status(200).json({})
} catch (e) {
......
const config = require('config')
const staffEmail = config.get('journal.staffEmail')
const journalName = config.get('journal.name')
const getEmailCopy = ({ emailType, titleText, targetUserName, comments }) => {
let paragraph
......@@ -34,6 +35,14 @@ const getEmailCopy = ({ emailType, titleText, targetUserName, comments }) => {
paragraph = `${targetUserName} has removed you from the role of Handling Editor for ${titleText}.<br/><br/>
The manuscript will no longer appear in your dashboard. Please contact ${staffEmail} if you have any questions about this change.`
break
case 'author-he-removed':
hasIntro = true
hasLink = false
hasSignature = true
paragraph = `The handling editor of your manuscript "${titleText}" had to be replaced. This may cause some delays in the peer review process.<br/><br/>
If you have questions please email them to ${staffEmail}<br/><br/>.
Thank you for your submission to ${journalName}.`
break
default:
throw new Error(`The ${emailType} email type is not defined.`)
}
......
......@@ -73,6 +73,56 @@ module.exports = {
return email.sendEmail()
},
notifyAuthorWhenHERemoved: async ({
baseUrl,
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 { submittingAuthor } = await fragmentHelper.getAuthorData({
UserModel,
})
const submittingAuthorName = `${submittingAuthor.firstName} ${
submittingAuthor.lastName
}`
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,
targetUserName: submittingAuthorName,
emailType: 'author-he-removed',
})
const email = new Email({
type: 'user',
fromEmail: `${eicName} <${staffEmail}>`,
toUser: {
email: submittingAuthor.email,
name: submittingAuthorName,
},
content: {
subject: `${customId}: Your manuscript's editor was changed`,
paragraph,
signatureName: eicName,
signatureJournal: journalName,
unsubscribeLink: services.createUrl(baseUrl, unsubscribeSlug, {
id: submittingAuthor.id,
token: submittingAuthor.accessTokens.unsubscribe,
}),
},
bodyProps,
})
return email.sendEmail()
},
sendEiCEmail: async ({
reason,
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