allow banned word / swearword blocker to apply to most public guilds (#9253)

* allow banned word / swearword blocker to apply to all public guilds, with specified exceptions

* add another guild

* add more guilds to those that do not have the bannedWords blocker applied

* fix lint errors
This commit is contained in:
Alys
2017-11-17 04:52:17 +10:00
committed by Matteo Pagliazzi
parent 67b16d91a3
commit 4814b0c52b
3 changed files with 165 additions and 3 deletions

View File

@@ -14,8 +14,8 @@ import pusher from '../../libs/pusher';
import nconf from 'nconf';
import Bluebird from 'bluebird';
import bannedWords from '../../libs/bannedWords';
import guildsAllowingBannedWords from '../../libs/guildsAllowingBannedWords';
import { getMatchesByWordArray } from '../../libs/stringUtils';
import { TAVERN_ID } from '../../models/group';
import bannedSlurs from '../../libs/bannedSlurs';
const FLAG_REPORT_EMAILS = nconf.get('FLAG_REPORT_EMAIL').split(',').map((email) => {
@@ -171,9 +171,11 @@ api.postChat = {
throw new NotAuthorized(res.t('chatPrivilegesRevoked'));
}
if (group._id === TAVERN_ID) {
// prevent banned words being posted, except in private guilds/parties and in certain public guilds with specific topics
if (group.privacy !== 'private' && !guildsAllowingBannedWords[group._id]) {
let matchedBadWords = getBannedWordsFromText(req.body.message);
if (matchedBadWords.length > 0) {
// @TODO replace this split mechanism with something that works properly in translations
let message = res.t('bannedWordUsed').split('.');
message[0] += ` (${matchedBadWords.join(', ')})`;
throw new BadRequest(message.join('.'));