Skip to content
Snippets Groups Projects
Commit 5ab05f63 authored by Bogdan Cochior's avatar Bogdan Cochior
Browse files

fix(user-manager): send 'Manuscript created' email only when admin adds author

parent 00d8f4aa
No related branches found
No related tags found
1 merge request!34Sprint 17 features
...@@ -13,7 +13,14 @@ const { ...@@ -13,7 +13,14 @@ const {
const { getEmailCopy } = require('./emailCopy') const { getEmailCopy } = require('./emailCopy')
module.exports = { module.exports = {
async sendNotifications({ user, baseUrl, fragment, UserModel, collection }) { async sendNotifications({
user,
baseUrl,
fragment,
UserModel,
collection,
reqUser,
}) {
const fragmentHelper = new Fragment({ fragment }) const fragmentHelper = new Fragment({ fragment })
const { title } = await fragmentHelper.getFragmentData({ const { title } = await fragmentHelper.getFragmentData({
handlingEditor: collection.handlingEditor, handlingEditor: collection.handlingEditor,
...@@ -48,13 +55,16 @@ module.exports = { ...@@ -48,13 +55,16 @@ module.exports = {
}) })
} }
sendAddedToManuscriptEmail({ const requestUser = await UserModel.find(reqUser)
email, if (requestUser.admin) {
baseUrl, sendAddedToManuscriptEmail({
user, email,
titleText, baseUrl,
subjectBaseText, user,
}) titleText,
subjectBaseText,
})
}
}, },
} }
......
...@@ -97,6 +97,7 @@ module.exports = models => async (req, res) => { ...@@ -97,6 +97,7 @@ module.exports = models => async (req, res) => {
baseUrl, baseUrl,
fragment, fragment,
collection, collection,
reqUser: req.user,
UserModel: models.User, UserModel: models.User,
}) })
......
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