feat(challenges): swear and slur blocker
This commit is contained in:
@@ -4,9 +4,7 @@ import { authWithHeaders, authWithSession } from '../../middlewares/auth';
|
||||
import { model as Challenge } from '../../models/challenge';
|
||||
import bannedWords from '../../libs/bannedWords';
|
||||
import bannedSlurs from '../../libs/bannedSlurs';
|
||||
import { getUserInfo } from '../../libs/email';
|
||||
import { getMatchesByWordArray } from '../../libs/stringUtils';
|
||||
import * as slack from '../../libs/slack';
|
||||
import {
|
||||
model as Group,
|
||||
basicFields as basicGroupFields,
|
||||
@@ -225,17 +223,25 @@ api.createChallenge = {
|
||||
const validationErrors = req.validationErrors();
|
||||
if (validationErrors) throw validationErrors;
|
||||
|
||||
const { savedChal, group } = await createChallenge(user, req, res);
|
||||
const group = await Group.getGroup({
|
||||
user, groupId: req.body.group, fields: basicGroupFields, optionalMembership: true,
|
||||
});
|
||||
|
||||
// checks challenge for slurs and banned words
|
||||
if (group.privacy === 'public'
|
||||
&& ((textContainsBannedSlur(req.body.name))
|
||||
|| (textContainsBannedSlur(req.body.shortName))
|
||||
|| (textContainsBannedSlur(req.body.summary))
|
||||
|| (textContainsBannedSlur(req.body.description)))) {
|
||||
|| (textContainsBannedSlur(req.body.description))
|
||||
|| (textContainsBannedWord(req.body.name))
|
||||
|| (textContainsBannedWord(req.body.shortName))
|
||||
|| (textContainsBannedWord(req.body.summary))
|
||||
|| (textContainsBannedWord(req.body.description)))) {
|
||||
throw new BadRequest(res.t('challengeBannedWordsAndSlurs'));
|
||||
}
|
||||
|
||||
const { savedChal } = await createChallenge(user, req, res);
|
||||
|
||||
await user.save();
|
||||
|
||||
const response = savedChal.toJSON();
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// Email admin@habitica.com to discuss the change you want made.
|
||||
//
|
||||
// All updates to this file must be done through a direct commit to limit
|
||||
// the words visibility in GitHub to protect our coders, socialites, and
|
||||
// the words visibility in GitHub to protect our coders and
|
||||
// wiki editors who look through PRs for information.
|
||||
//
|
||||
// When adding words that contain asterisks, put two backslashes before them.
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
// CONTENT WARNING:
|
||||
//
|
||||
// This file contains slurs, swear words, religious oaths, and words related
|
||||
// to addictive substance and adult topics.
|
||||
// This file contains slurs, swear words, and religious oaths.
|
||||
// Do not read this file if you do not want to be exposed to those words.
|
||||
//
|
||||
// The words are stored in an array called `bannedWords` which is then
|
||||
@@ -18,7 +17,7 @@
|
||||
// Email admin@habitica.com to discuss the change you want made.
|
||||
//
|
||||
// All updates to this file must be done through a direct commit to limit
|
||||
// the words visibility in GitHub to protect our coders, socialites, and
|
||||
// the words visibility in GitHub to protect our coders and
|
||||
// wiki editors who look through PRs for information.
|
||||
//
|
||||
// When adding words that contain asterisks, put two backslashes before them.
|
||||
@@ -85,13 +84,20 @@ const bannedWords = [
|
||||
|
||||
|
||||
|
||||
'damn',
|
||||
'goddamn',
|
||||
'damnit',
|
||||
'dammit',
|
||||
'damned',
|
||||
'omfg',
|
||||
|
||||
'ass',
|
||||
'arse',
|
||||
'arsehole',
|
||||
'asshole',
|
||||
'badarse',
|
||||
'badass',
|
||||
'bastard',
|
||||
'bastards',
|
||||
'bitch',
|
||||
'bitchy',
|
||||
'bitches',
|
||||
'bitching',
|
||||
'b\\*tch',
|
||||
'blowjob',
|
||||
'bugger',
|
||||
'buggery',
|
||||
'buggering',
|
||||
@@ -101,6 +107,57 @@ const bannedWords = [
|
||||
'bullshitter',
|
||||
'bullshiting',
|
||||
'bullshitting',
|
||||
'cocksucker',
|
||||
'cocksucking',
|
||||
'cunnilingus',
|
||||
'dafuq',
|
||||
'fag',
|
||||
'fap',
|
||||
'fapping',
|
||||
'fellatio',
|
||||
'fuck',
|
||||
'fucks',
|
||||
'fucking',
|
||||
'fucked',
|
||||
'fuckwit',
|
||||
'fucker',
|
||||
'fuckers',
|
||||
'f\\*ck',
|
||||
'fuckhead',
|
||||
'fuckheads',
|
||||
'goddamn',
|
||||
'handjob',
|
||||
'kickarse',
|
||||
'kickass',
|
||||
'lmao',
|
||||
'lmfao',
|
||||
'omfg',
|
||||
'masturbate',
|
||||
'masturbates',
|
||||
'masturbating',
|
||||
'masturbation',
|
||||
'milf',
|
||||
'motherfucker',
|
||||
'motherfuckers',
|
||||
'motherfucking',
|
||||
'muthafucka',
|
||||
'nigga',
|
||||
'niggas',
|
||||
'nofap',
|
||||
'no fap',
|
||||
'no-fap',
|
||||
'no nut',
|
||||
'no-nut',
|
||||
'no-nut-november',
|
||||
'nutting',
|
||||
'nuttin',
|
||||
'rape',
|
||||
'raped',
|
||||
'raping',
|
||||
'r\\*pe',
|
||||
'r\\*ped',
|
||||
'r\\*ping',
|
||||
'rimjob',
|
||||
'shiz',
|
||||
'shit',
|
||||
'shite',
|
||||
@@ -114,81 +171,12 @@ const bannedWords = [
|
||||
'sh\\*t',
|
||||
'sh\\*tty',
|
||||
'sh\\*tting',
|
||||
'fuck',
|
||||
'fucks',
|
||||
'fucking',
|
||||
'fucked',
|
||||
'fuckwit',
|
||||
'fucker',
|
||||
'fuckers',
|
||||
'f\\*ck',
|
||||
'fuckhead',
|
||||
'fuckheads',
|
||||
'motherfucker',
|
||||
'motherfuckers',
|
||||
'motherfucking',
|
||||
'muthafucka',
|
||||
'dafuq',
|
||||
'wtf',
|
||||
'stfu',
|
||||
|
||||
'ass',
|
||||
'arse',
|
||||
'asshole',
|
||||
'badass',
|
||||
'kickass',
|
||||
'arsehole',
|
||||
'badarse',
|
||||
'kickarse',
|
||||
'lmao',
|
||||
'lmfao',
|
||||
|
||||
'bitch',
|
||||
'bitchy',
|
||||
'bitches',
|
||||
'bitching',
|
||||
'b\\*tch',
|
||||
|
||||
'fag',
|
||||
'slut',
|
||||
'sluts',
|
||||
'nigga',
|
||||
'niggas',
|
||||
'bastard',
|
||||
'bastards',
|
||||
|
||||
'rape',
|
||||
'raped',
|
||||
'raping',
|
||||
'r\\*pe',
|
||||
'r\\*ped',
|
||||
'r\\*ping',
|
||||
'blowjob',
|
||||
'rimjob',
|
||||
'handjob',
|
||||
'cunnilingus',
|
||||
'fellatio',
|
||||
'sodomy',
|
||||
'milf',
|
||||
'cocksucker',
|
||||
'cocksucking',
|
||||
'fap',
|
||||
'nofap',
|
||||
'no fap',
|
||||
'no-fap',
|
||||
'fapping',
|
||||
'no nut',
|
||||
'no-nut',
|
||||
'no-nut-november',
|
||||
'nutting',
|
||||
'nuttin',
|
||||
'masturbate',
|
||||
'masturbates',
|
||||
'masturbating',
|
||||
'masturbation',
|
||||
'stfu',
|
||||
'wtf',
|
||||
|
||||
'heroin',
|
||||
'cocaine',
|
||||
];
|
||||
|
||||
export default bannedWords;
|
||||
|
||||
Reference in New Issue
Block a user