mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Squashed commit of the following:
commit83bcd07e20Author: SabreCat <sabrecat@gmail.com> Date: Fri Dec 22 17:24:45 2023 -0600 fix(profile): revert state on error commit6aa6278727Author: SabreCat <sabrecat@gmail.com> Date: Fri Dec 22 14:37:28 2023 -0600 fix(test): no longer care about swears in profile commit0882c77038Author: SabreCat <sabe@habitica.com> Date: Fri Dec 22 14:15:42 2023 -0600 fix(lint): remove unused functions commit9b275ef72dAuthor: SabreCat <sabe@habitica.com> Date: Fri Dec 22 14:09:11 2023 -0600 fix(profiles): restore reporting functionality Also remove unused and/or unrelated code and clean up comments commitf4ed8c1461Merge:da16aa9c75f8ba191eeaAuthor: SabreCat <sabe@habitica.com> Date: Fri Dec 22 12:11:00 2023 -0600 Merge branch 'release' into slur-swear-blocker commitda16aa9c75Author: CuriousMagpie <eilatan@gmail.com> Date: Thu Dec 21 13:20:28 2023 -0500 feat(s/s blocker): challenge updates to slack commit51bed61c4cAuthor: CuriousMagpie <eilatan@gmail.com> Date: Tue Dec 19 15:36:59 2023 -0500 feat(s/s blocker): work on challenges commit139cbcb21cAuthor: CuriousMagpie <eilatan@gmail.com> Date: Wed Dec 13 13:20:45 2023 -0500 fix(slack): update Slack notification to include authorEmail and remove undefined commit805b287721Author: SabreCat <sabe@habitica.com> Date: Tue Dec 12 16:35:54 2023 -0600 fix(profiles): improve profanity check logic commit02ef7e8822Author: CuriousMagpie <eilatan@gmail.com> Date: Tue Dec 12 17:22:29 2023 -0500 feat(slur blocker): arghhhhhh commit949dee9b1eAuthor: CuriousMagpie <eilatan@gmail.com> Date: Tue Dec 12 13:57:29 2023 -0500 feat(slur blocker): more refactoring commitbf953998f4Merge:d21aa687b7f572aa442eAuthor: CuriousMagpie <eilatan@gmail.com> Date: Mon Dec 11 15:20:06 2023 -0500 Merge branch 'release' into slur-swear-blocker commitd21aa687b7Author: CuriousMagpie <eilatan@gmail.com> Date: Thu Dec 7 18:00:29 2023 -0500 feat(slur blocker): refactoring code commitf2db90c494Author: CuriousMagpie <eilatan@gmail.com> Date: Wed Dec 6 12:12:55 2023 -0500 feat(slur/swear blocker): work on Profiles commit8f9822ffe8Author: CuriousMagpie <eilatan@gmail.com> Date: Mon Dec 4 17:25:17 2023 -0500 feat(profiles/challenges): work on profile block & slack report commitbdb2e06e5eAuthor: CuriousMagpie <eilatan@gmail.com> Date: Fri Dec 1 16:11:27 2023 -0500 feat(slur/swear): working on it commit7277b5cad5Merge:24d14277ab941f1f976cAuthor: CuriousMagpie <eilatan@gmail.com> Date: Fri Dec 1 15:04:46 2023 -0500 Merge branch 'profile-slur-swear-blocker' into slur-swear-blocker commit941f1f976cAuthor: CuriousMagpie <eilatan@gmail.com> Date: Thu Nov 30 14:34:30 2023 -0500 feat(profiles/PMs): slur/swear blocker upgrade commit0863017efcAuthor: CuriousMagpie <eilatan@gmail.com> Date: Tue Nov 28 16:21:21 2023 -0500 feat(profiles): slur/swear blocker commite9937d864fAuthor: CuriousMagpie <eilatan@gmail.com> Date: Mon Nov 27 15:24:37 2023 -0500 feat(profiles): slur/swear blocker commit24d14277abAuthor: CuriousMagpie <eilatan@gmail.com> Date: Mon Nov 27 14:12:46 2023 -0500 feat(challenges): update behavior based on public/private groups commit1251f5b6a7Author: CuriousMagpie <eilatan@gmail.com> Date: Tue Nov 14 16:28:29 2023 -0500 feat(challenges): swear and slur blocker commita771045ca7Author: CuriousMagpie <eilatan@gmail.com> Date: Tue Nov 14 15:46:16 2023 -0500 feat(challenges): even more slur blocker commite5e91aa78aAuthor: CuriousMagpie <eilatan@gmail.com> Date: Tue Nov 14 14:31:25 2023 -0500 feat(challenges): more slur blocker commit50e824e4e3Author: CuriousMagpie <eilatan@gmail.com> Date: Mon Nov 13 15:12:14 2023 -0500 feat(challenges): slur blocker commit315ea24ef4Author: CuriousMagpie <eilatan@gmail.com> Date: Fri Nov 3 12:31:12 2023 -0400 feat(challenges): slur blocker work commit0f742d219fAuthor: CuriousMagpie <eilatan@gmail.com> Date: Thu Nov 2 16:22:31 2023 -0400 feat(challenges): add banned words & slur blocker to challenges commit40d6b60ee3Author: CuriousMagpie <eilatan@gmail.com> Date: Mon Oct 23 13:00:46 2023 -0400 update packages on local/origin repo
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import * as slack from '../slack';
|
||||
import { getUserInfo } from '../email';
|
||||
import common from '../../../common';
|
||||
import * as Tasks from '../../models/task';
|
||||
import { model as Groups } from '../../models/group';
|
||||
@@ -105,19 +107,6 @@ function checkPreferencePurchase (user, path, item) {
|
||||
return _.get(user.purchased, itemPath);
|
||||
}
|
||||
|
||||
async function checkNewInputForProfanity (user, res, newValue) {
|
||||
const containsSlur = stringContainsProfanity(newValue, 'slur');
|
||||
const containsBannedWord = stringContainsProfanity(newValue);
|
||||
if (containsSlur || containsBannedWord) {
|
||||
if (containsSlur) {
|
||||
user.flags.chatRevoked = true;
|
||||
await user.save();
|
||||
throw new BadRequest(res.t('bannedSlurUsedInProfile'));
|
||||
}
|
||||
throw new BadRequest(res.t('bannedWordUsedInProfile'));
|
||||
}
|
||||
}
|
||||
|
||||
export async function update (req, res, { isV3 = false }) {
|
||||
const { user } = res.locals;
|
||||
|
||||
@@ -134,17 +123,40 @@ export async function update (req, res, { isV3 = false }) {
|
||||
});
|
||||
}
|
||||
|
||||
let slurWasUsed = false;
|
||||
let problemContent = '';
|
||||
|
||||
if (req.body['profile.name'] !== undefined) {
|
||||
const newName = req.body['profile.name'];
|
||||
if (newName === null) throw new BadRequest(res.t('invalidReqParams'));
|
||||
if (newName.length > 30) throw new BadRequest(res.t('displaynameIssueLength'));
|
||||
if (nameContainsNewline(newName)) throw new BadRequest(res.t('displaynameIssueNewline'));
|
||||
await checkNewInputForProfanity(user, res, newName);
|
||||
if (stringContainsProfanity(newName, 'slur')) {
|
||||
slurWasUsed = true;
|
||||
problemContent += `Profile Name: ${newName}\n\n`;
|
||||
}
|
||||
}
|
||||
|
||||
if (req.body['profile.blurb'] !== undefined) {
|
||||
const newBlurb = req.body['profile.blurb'];
|
||||
await checkNewInputForProfanity(user, res, newBlurb);
|
||||
if (stringContainsProfanity(newBlurb, 'slur')) {
|
||||
slurWasUsed = true;
|
||||
problemContent += `Profile Blurb: ${newBlurb}`;
|
||||
}
|
||||
}
|
||||
|
||||
if (slurWasUsed) {
|
||||
const authorEmail = getUserInfo(user, ['email']).email;
|
||||
user.flags.chatRevoked = true;
|
||||
await user.save();
|
||||
slack.sendProfileSlurNotification({
|
||||
authorEmail,
|
||||
author: user.auth.local.username,
|
||||
uuid: user.id,
|
||||
language: user.preferences.language,
|
||||
problemContent,
|
||||
});
|
||||
throw new BadRequest(res.t('bannedSlurUsedInProfile'));
|
||||
}
|
||||
|
||||
let groupsToMirror;
|
||||
|
||||
Reference in New Issue
Block a user