mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
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:
@@ -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('.'));
|
||||
|
||||
Reference in New Issue
Block a user