Skip to content
Snippets Groups Projects
Commit dd242ba6 authored by Tania Fecheta's avatar Tania Fecheta
Browse files

fix(fragmentRecommendations): reviewers can add only one review on the current version

parent 3d758786
No related branches found
No related tags found
3 merge requests!160Update staging with master features,!156Develop,!154Hin 1132
......@@ -58,6 +58,8 @@ module.exports = models => async (req, res) => {
})
}
const fragmentRecommendations = get(fragment, 'recommendations', [])
const authsome = authsomeHelper.getAuthsome(models)
const target = {
fragment,
......@@ -87,6 +89,17 @@ module.exports = models => async (req, res) => {
.json({ error: 'Cannot write a review on an older version.' })
}
if (
(recommendationType === recommendations.type.review ||
recommendationType === recommendations.type.editor) &&
last(collection.fragments) === fragmentId &&
!isEmpty(fragmentRecommendations.filter(r => r.userId === req.user))
) {
return res
.status(400)
.json({ error: 'Cannot write another review on this version.' })
}
if (
recommendation === recommendations.publish &&
recommendationType === recommendations.type.editor &&
......
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