Rejecting comments on the server if the character count is too long.

This commit is contained in:
David Jay
2016-12-13 13:36:54 -05:00
parent 4dca9ff061
commit 643373e224
2 changed files with 29 additions and 1 deletions
+7 -1
View File
@@ -97,7 +97,13 @@ router.post('/', wordlist.filter('body'), (req, res, next) => {
// Return `premod` if pre-moderation is enabled and an empty "new" status
// in the event that it is not in pre-moderation mode.
.then(({moderation}) => moderation === 'pre' ? 'premod' : '');
.then(({moderation, charCountEnable, charCount}) => {
// Reject if the comment is too long
if (charCountEnable && body.length > charCount) {
return 'rejected';
}
return moderation === 'pre' ? 'premod' : '';
});
}
status.then((status) => Comment.publicCreate({