mirror of
https://github.com/wassname/talk.git
synced 2026-08-11 11:27:10 +08:00
Comment too short fixes
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user