Comment too short fixes

This commit is contained in:
Wyatt Johnson
2017-05-12 11:16:52 -06:00
parent e3017efebf
commit ffd96f57e9
3 changed files with 13 additions and 0 deletions
+1
View File
@@ -33,6 +33,7 @@
"unexpectedError": "Unexpected error while saving changes. Sorry!"
},
"error": {
"COMMENT_TOO_SHORT": "Your comment must have something in it",
"EDIT_WINDOW_ENDED": "You can no longer edit this comment. The time window to do so has expired.",
"emailNotVerified": "Email address {0} not verified.",
"email": "Not a valid E-Mail",
+7
View File
@@ -162,6 +162,12 @@ const ErrEditWindowHasEnded = new APIError('Edit window is over', {
status: 403
});
// ErrCommentTooShort is returned when the comment is too short.
const ErrCommentTooShort = new APIError('Comment was too short', {
translation_key: 'COMMENT_TOO_SHORT',
status: 400
});
module.exports = {
ExtendableError,
APIError,
@@ -185,4 +191,5 @@ module.exports = {
ErrInstallLock,
ErrLoginAttemptMaximumExceeded,
ErrEditWindowHasEnded,
ErrCommentTooShort
};
+5
View File
@@ -85,6 +85,11 @@ const filterNewComment = (context, {body, asset_id}) => {
*/
const resolveNewCommentStatus = async (context, {asset_id, body}, wordlist = {}, settings = {}) => {
// Check to see if the body is too short, if it is, then complain about it!
if (body.length < 2) {
throw errors.ErrCommentTooShort;
}
// Decide the status based on whether or not the current asset/settings
// has pre-mod enabled or not. If the comment was rejected based on the
// wordlist, then reject it, otherwise if the moderation setting is