Skip to content
Snippets Groups Projects
Commit b046ea77 authored by Sebastian's avatar Sebastian
Browse files

feat(component-invite): add agree url

parent 6b1a1c5d
No related branches found
No related tags found
1 merge request!6Agree/Decline to work on a manuscript
......@@ -36,6 +36,7 @@ const setupReviewerInvitation = async (
collection,
user,
mailService,
invitationId,
) => {
const baseUrl = `${req.protocol}://${req.get('host')}`
const fragment = await models.Fragment.find(collection.fragments[0])
......@@ -59,6 +60,8 @@ const setupReviewerInvitation = async (
title,
submittingAuthor,
authors,
fragment.id,
invitationId,
)
}
......
......@@ -75,6 +75,7 @@ module.exports = models => async (req, res) => {
collection,
user,
mailService,
invitation.id,
)
} else {
return res.status(500).json({
......@@ -109,13 +110,18 @@ module.exports = models => async (req, res) => {
collection = await collection.save()
}
await teamHelper.setupManuscriptTeam(models, newUser, collectionId, role)
await collectionHelper.addInvitation(collection, newUser.id, role)
const invitation = await collectionHelper.addInvitation(
collection,
newUser.id,
role,
)
await invitationHelper.setupReviewerInvitation(
req,
models,
collection,
newUser,
mailService,
invitation.id,
)
return res.status(200).json(newUser)
}
......
......@@ -4,7 +4,7 @@ const querystring = require('querystring')
const Email = require('@pubsweet/component-send-email')
const config = require('config')
const resetPath = config.get('invite-reset-password.url')
const resetPasswordPath = config.get('invite-reviewer.url')
module.exports = {
setupInviteEmail: async (user, emailType, inviteUrl) => {
......@@ -144,14 +144,19 @@ module.exports = {
title,
submittingAuthor,
authors,
fragmentId,
invitationId,
) => {
const subject = `${collection.customId}: Review Requested`
let agreeUrl
let agreeUrl = `${baseUrl}/projects/${
collection.id
}/versions/${fragmentId}/details?${querystring.encode({
invitationId,
agree: true,
})}`
const declineUrl = ''
if (invitedUser.isConfirmed) {
agreeUrl = ''
} else {
agreeUrl = `${baseUrl}${resetPath}?${querystring.encode({
if (!invitedUser.isConfirmed) {
agreeUrl = `${baseUrl}${resetPasswordPath}?${querystring.encode({
email: invitedUser.email,
token: invitedUser.passwordResetToken,
collectionId: collection.id,
......
......@@ -61,6 +61,9 @@ module.exports = {
'invite-reset-password': {
url: process.env.PUBSWEET_INVITE_PASSWORD_RESET_URL || '/invite',
},
'invite-reviewer': {
url: process.env.PUBSWEET_INVITE_REVIEWER_URL || '/invite-reviewer',
},
roles: {
global: ['admin', 'editorInChief', 'author', 'handlingEditor'],
collection: ['handlingEditor', 'reviewer', 'author'],
......
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