Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Body Count #1969

Merged
merged 3 commits into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,20 @@ class ErrCommentTooShort extends TalkError {
}
}

// ErrCommentTooLong is returned when the comment is too long.
class ErrCommentTooLong extends TalkError {
constructor(length, allowed) {
super(
'Comment was too long',
{
translation_key: 'COMMENT_TOO_LONG',
status: 400,
},
{ length, allowed }
);
}
}

// ErrAssetURLAlreadyExists is returned when a rename operation is requested
// but an asset already exists with the new url.
class ErrAssetURLAlreadyExists extends TalkError {
Expand Down Expand Up @@ -413,13 +427,15 @@ module.exports = {
ErrAssetURLAlreadyExists,
ErrAuthentication,
ErrCannotIgnoreStaff,
ErrCommentTooShort,
ErrCommentingDisabled,
ErrCommentTooLong,
ErrCommentTooShort,
ErrContainsProfanity,
ErrEditWindowHasEnded,
ErrEmailAlreadyVerified,
ErrEmailTaken,
ErrEmailVerificationToken,
ErrHTTPNotFound,
ErrInstallLock,
ErrInvalidAssetURL,
ErrLoginAttemptMaximumExceeded,
Expand All @@ -441,5 +457,4 @@ module.exports = {
ErrSpecialChars,
ErrUsernameTaken,
ExtendableError,
ErrHTTPNotFound,
};
2 changes: 1 addition & 1 deletion locales/ar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ ar:
CANNOT_IGNORE_STAFF: 'لا يمكن تجاهل الموظفين.'
COMMENT_PARENT_NOT_VISIBLE: 'التعليق الذي ترد عليه تمت إزالته أو غير موجود.'
COMMENT_TOO_SHORT: 'يجب أن تكون التعليقات أكثر من حرف واحد، يرجى مراجعة تعليقك وإعادة المحاولة.'
COMMENT_TOO_LONG: 'يتجاوز النص الحد الأقصى للطول المسموح'
COMMENTING_CLOSED: 'تم إغلاق فاعلية التعليق'
COMMENTING_DISABLED: 'التعليق معطّل حاليًا على هذا الموقع'
confirm_password: 'كلمات المرور غير متطابقة. يرجى التحقق مرة أخرى'
Expand Down Expand Up @@ -281,7 +282,6 @@ ar:
reasons:
comment:
banned_word: 'كلمة محظورة'
body_count: 'يتجاوز النص الحد الأقصى للطول المسموح'
comment_noagree: أعارض
comment_offensive: مسيء
comment_other: آخر
Expand Down
2 changes: 1 addition & 1 deletion locales/da.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ da:
CANNOT_IGNORE_STAFF: 'Kan ikke ignorere personale.'
COMMENT_PARENT_NOT_VISIBLE: 'Den kommentar, du svarer på er blevet fjernet eller eksisterer ikke.'
COMMENT_TOO_SHORT: 'Din kommentar skal indeholde noget'
COMMENT_TOO_LONG: 'Body overstiger max længde'
COMMENTING_CLOSED: 'Kommentering er allerede lukket'
confirm_password: 'Kodeordene matcher ikke. Tjek venligst igen.'
EDIT_USERNAME_NOT_AUTHORIZED: 'Du har ikke tilladelse til at opdatere dit brugernavn.'
Expand Down Expand Up @@ -238,7 +239,6 @@ da:
reasons:
comment:
banned_word: 'Forbudt ord'
body_count: 'Body overstiger max længde'
comment_noagree: Uenig
comment_offensive: Offensiv
comment_other: Andre
Expand Down
2 changes: 1 addition & 1 deletion locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ de:
CANNOT_IGNORE_STAFF: 'Mitarbeiter können nicht ignoriert werden.'
COMMENT_PARENT_NOT_VISIBLE: 'Der Kommentar, auf den Sie antworten möchten, wurde entfernt oder existiert nicht.'
COMMENT_TOO_SHORT: 'Kommentare sollten mehr als ein Zeichen enthalten, bitte überprüfen Sie Ihren Kommentar und probieren Sie es erneut.'
COMMENT_TOO_LONG: 'Text überschreitet Zeichenlimit'
COMMENTING_CLOSED: 'Kommentarbereich ist bereits geschlossen'
COMMENTING_DISABLED: 'Die Kommentarfunktion ist derzeit abgeschaltet'
confirm_password: 'Passwörter nicht identisch. Bitte erneut überprüfen'
Expand Down Expand Up @@ -273,7 +274,6 @@ de:
reasons:
comment:
banned_word: 'Unzulässiges Wort'
body_count: 'Text überschreitet Zeichenlimit'
comment_noagree: 'Andere Meinung'
comment_offensive: Unangemessen
comment_other: Anderes
Expand Down
2 changes: 1 addition & 1 deletion locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ en:
CANNOT_IGNORE_STAFF: 'Cannot ignore Staff members.'
COMMENT_PARENT_NOT_VISIBLE: 'The comment that you''re replying to has been removed or doesn''t exist.'
COMMENT_TOO_SHORT: 'Comments should be more than one character, please revise your comment and try again.'
COMMENT_TOO_LONG: 'Body exceeds max length'
COMMENTING_CLOSED: 'Commenting is already closed'
COMMENTING_DISABLED: 'Commenting is currently disabled on this site'
confirm_password: 'Passwords don''t match. Please check again'
Expand Down Expand Up @@ -286,7 +287,6 @@ en:
reasons:
comment:
banned_word: 'Banned Word'
body_count: 'Body exceeds max length'
comment_noagree: Disagree
comment_offensive: Offensive
comment_other: Other
Expand Down
2 changes: 1 addition & 1 deletion locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ es:
CANNOT_IGNORE_STAFF: 'No puede ignorar a miembros del Staff.'
COMMENT_PARENT_NOT_VISIBLE: 'El comentario a la que estás contestando ha sido eliminado o no existe.'
COMMENT_TOO_SHORT: 'Tu comentario debe tener algo escrito'
COMMENT_TOO_LONG: 'El texto excede el límite permitido'
COMMENTING_CLOSED: 'Los comentarios ya estan cerrados'
confirm_password: 'Las contraseñas no coinciden. Inténtelo nuevamente'
EDIT_USERNAME_NOT_AUTHORIZED: 'No tiene permiso para editar el nombre de usuario.'
Expand Down Expand Up @@ -260,7 +261,6 @@ es:
reasons:
comment:
banned_word: 'Palabra prohibida'
body_count: 'El texto exede el límite permitido'
comment_noagree: 'No está de acuerdo'
comment_offensive: 'Es ofensivo'
comment_other: 'Otra razón'
Expand Down
2 changes: 1 addition & 1 deletion locales/fi_FI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ fi_FI:
CANNOT_IGNORE_STAFF: 'Työntekijöitä ei voi jättää huomioimatta'
COMMENT_PARENT_NOT_VISIBLE: 'Kommenttia, johon yrität vastata, ei enää ole.'
COMMENT_TOO_SHORT: 'Kommentin tulee olla vähintään kaksi merkkiä pitkä. Tarkista kirjoittamasi teksti.'
COMMENT_TOO_LONG: Liian pitkä viesti'
COMMENTING_CLOSED: 'Kommentointi on suljettu'
confirm_password: 'Salasanat eivät täsmää. Tarkista, ole hyvä.'
EDIT_USERNAME_NOT_AUTHORIZED: 'Sinulla ei ole oikeutta päivittää tai muokata käyttäjänimeä.'
Expand Down Expand Up @@ -240,7 +241,6 @@ fi_FI:
reasons:
comment:
banned_word: 'Kielletty sana'
body_count: 'Liian pitkä viesti'
comment_noagree: 'Olen eri mieltä'
comment_offensive: Loukkaava
comment_other: Muu
Expand Down
2 changes: 1 addition & 1 deletion locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ fr:
CANNOT_IGNORE_STAFF: 'Ne peut pas ignorer les membres de l''équipe.'
COMMENT_PARENT_NOT_VISIBLE: 'Le commentaire auquel vous répondez a été supprimé ou n’existe plus.'
COMMENT_TOO_SHORT: 'Votre commentaire doit contenir quelque chose'
COMMENT_TOO_LONG: 'Le texte dépasse la longueur maximale'
COMMENTING_CLOSED: 'Les commentaires sont déjà fermés'
confirm_password: 'Les mots de passe ne correspondent pas. Vérifiez à nouveau'
EDIT_USERNAME_NOT_AUTHORIZED: 'Vous n''avez pas la permission de mettre à jour votre nom d''utilisateur.'
Expand Down Expand Up @@ -235,7 +236,6 @@ fr:
reasons:
comment:
banned_word: 'Mot banni'
body_count: 'Le texte dépasse la longueur maximale'
comment_noagree: 'Pas d’accord'
comment_offensive: Offensive
comment_other: Autre
Expand Down
2 changes: 1 addition & 1 deletion locales/nl_NL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ nl_NL:
CANNOT_IGNORE_STAFF: 'Kan geen Staff-leden negeren.'
COMMENT_PARENT_NOT_VISIBLE: 'De reactie waarop je probeert te reageren bestaat niet of is inmiddels verwijderd.'
COMMENT_TOO_SHORT: 'Reacties moeten meer dan één teken hebben. Herzie je reactie en probeer opnieuw.'
COMMENT_TOO_LONG: 'Tekst is te lang'
COMMENTING_CLOSED: 'Reageren is al afgesloten.'
confirm_password: 'Wachtwoorden komen niet overeen. Controleer opnieuw.'
EDIT_USERNAME_NOT_AUTHORIZED: 'Je bent niet gemachtigd om je gebruikersnaam te wijzigen.'
Expand Down Expand Up @@ -239,7 +240,6 @@ nl_NL:
reasons:
comment:
banned_word: 'Geblokeerd woord'
body_count: 'Tekst is te lang'
comment_noagree: 'Niet eens'
comment_offensive: Aanstootgevend
comment_other: Anders
Expand Down
17 changes: 2 additions & 15 deletions services/moderation/phases/commentLength.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ErrCommentTooShort } = require('../../../errors');
const { ErrCommentTooShort, ErrCommentTooLong } = require('../../../errors');

// This phase checks to see if the comment is long enough.
module.exports = (
Expand All @@ -17,19 +17,6 @@ module.exports = (

// Reject if the comment is too long
if (charCountEnable && comment.body.length > charCount) {
// Add the flag related to Trust to the comment.
return {
status: 'REJECTED',
actions: [
{
action_type: 'FLAG',
user_id: null,
group_id: 'BODY_COUNT',
metadata: {
count: comment.body.length,
},
},
],
};
throw new ErrCommentTooLong(comment.body.length, charCount);
}
};