Frontend support and adjustments of current banned words blocking code to support new implementation (Fixes #12405) (#12496)

* Added the "Allow banned words" checkbox to create/update guild forms

Added the "Allow banned words" checkbox to guild create/update forms which are only visible to Admins

* Updated create/update group API to include bannedWordsAllowed property

Added logic to set bannedWordsAllowed depending on conditions

* Updated word banning logic to use bannedWordsAllowed guild value instead

Updated word banning logic to use bannedWordsAllowed guild value and deleted hardcoded guild file & import

* Updated banned words test

* Pull Request amends

Removed the setting of bannedWordsAllowed during group creation
Added v-once to elements
Updated existing test and added tests related to bannedWordsAllowed functionality

* Small amend

* Small amend

Removed leftover code that was left during testing
This commit is contained in:
Scott
2020-09-11 09:29:30 +01:00
committed by GitHub
parent c89f66e4b8
commit 5716b4eb72
7 changed files with 114 additions and 151 deletions

View File

@@ -18,7 +18,6 @@ import * as slack from '../../libs/slack';
import { chatReporterFactory } from '../../libs/chatReporting/chatReporterFactory';
import { getAuthorEmailFromMessage } from '../../libs/chat';
import bannedWords from '../../libs/bannedWords';
import guildsAllowingBannedWords from '../../libs/guildsAllowingBannedWords';
import { getMatchesByWordArray } from '../../libs/stringUtils';
import bannedSlurs from '../../libs/bannedSlurs';
import apiError from '../../libs/apiError';
@@ -172,7 +171,7 @@ api.postChat = {
// prevent banned words being posted, except in private guilds/parties
// and in certain public guilds with specific topics
if (group.privacy === 'public' && !guildsAllowingBannedWords[group._id]) {
if (group.privacy === 'public' && !group.bannedWordsAllowed) {
const matchedBadWords = getBannedWordsFromText(req.body.message);
if (matchedBadWords.length > 0) {
throw new BadRequest(res.t('bannedWordUsed', { swearWordsUsed: matchedBadWords.join(', ') }));