diff --git a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js index c0301c0d5162d064f9b89c3fc660f1d745562b3f..3ab4592d8e7df569c2b9cdafeb32b34c88c35242 100644 --- a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js +++ b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js @@ -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 &&