From f2db90c494b6c2705721e1b9fdbf503aec7ad7d8 Mon Sep 17 00:00:00 2001 From: CuriousMagpie Date: Wed, 6 Dec 2023 12:12:55 -0500 Subject: [PATCH] feat(slur/swear blocker): work on Profiles --- habitica-images | 2 +- website/common/locales/en/groups.json | 2 +- .../server/controllers/api-v3/challenges.js | 35 ++++++++++--------- website/server/libs/slack.js | 13 +++---- website/server/libs/user/index.js | 7 ++-- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/habitica-images b/habitica-images index f74a3b4e97..60b9a912a2 160000 --- a/habitica-images +++ b/habitica-images @@ -1 +1 @@ -Subproject commit f74a3b4e974b76ac804ceb8cf48aad9993090a21 +Subproject commit 60b9a912a2b2b5b5ed3ee7ebf768be0487da21cb diff --git a/website/common/locales/en/groups.json b/website/common/locales/en/groups.json index f5cc5652a6..4311d0e973 100644 --- a/website/common/locales/en/groups.json +++ b/website/common/locales/en/groups.json @@ -18,7 +18,7 @@ "communityGuidelines": "Community Guidelines", "bannedWordUsed": "Oops! Looks like this post contains a swear word or reference to an addictive substance or adult topic (<%= swearWordsUsed %>). Habitica keeps our chat very clean. Feel free to edit your message so you can post it! You must remove the word, not just censor it.", "bannedSlurUsed": "Your post contained inappropriate language, and your chat privileges have been revoked.", - "challengeBannedSlurs": "Your Challenge contains a slur which violate Habitica’s community guidelines and your chat and Challenge creation privileges have been revoked. Contact admin@habitica.com for more information.", + "challengeBannedSlurs": "Your Challenge contains a slur which violates Habitica’s community guidelines and your chat and Challenge creation privileges have been revoked. Contact admin@habitica.com for more information.", "challengeBannedWords": "Your Challenge contains one or more swear words or references to an adult topic. Please edit your Challenge so you can save it. You must remove the word, not just censor it.", "challengeBannedSlursPrivate": "Your Challenge contains a slur which violates Habitica's community guidelines. Please remove it in order to save your Challenge.", "party": "Party", diff --git a/website/server/controllers/api-v3/challenges.js b/website/server/controllers/api-v3/challenges.js index 418d2d1925..188968effb 100644 --- a/website/server/controllers/api-v3/challenges.js +++ b/website/server/controllers/api-v3/challenges.js @@ -269,24 +269,25 @@ api.createChallenge = { throw new BadRequest(res.t('challengeBannedWords')); } - // checks private challenge for slurs - if (group.privacy === 'private' - && ((textContainsBannedSlur(req.body.name)) - || (textContainsBannedSlur(req.body.shortName)) - || (textContainsBannedSlur(req.body.summary)) - || (textContainsBannedSlur(req.body.description)))) { - // toast notification - throw new BadRequest(res.t('challengeBannedSlursPrivate')); - } + // Not checking challenges in private spaces for slurs or swears + // // checks private challenge for slurs + // if (group.privacy === 'private' + // && ((textContainsBannedSlur(req.body.name)) + // || (textContainsBannedSlur(req.body.shortName)) + // || (textContainsBannedSlur(req.body.summary)) + // || (textContainsBannedSlur(req.body.description)))) { + // // toast notification + // throw new BadRequest(res.t('challengeBannedSlursPrivate')); + // } - // checks private challenge for swears -- allowed unless user flags - if (group.privacy === 'private' - && ((textContainsBannedWord(req.body.name)) - || (textContainsBannedWord(req.body.shortName)) - || (textContainsBannedWord(req.body.summary)) - || (textContainsBannedWord(req.body.description)))) { - await user.save(); - } + // // checks private challenge for swears -- allowed unless user flags + // if (group.privacy === 'private' + // && ((textContainsBannedWord(req.body.name)) + // || (textContainsBannedWord(req.body.shortName)) + // || (textContainsBannedWord(req.body.summary)) + // || (textContainsBannedWord(req.body.description)))) { + // await user.save(); + // } const { savedChal } = await createChallenge(user, req, res); diff --git a/website/server/libs/slack.js b/website/server/libs/slack.js index 18816c91f3..309ae7076c 100644 --- a/website/server/libs/slack.js +++ b/website/server/libs/slack.js @@ -386,8 +386,9 @@ function sendProfileSlurNotification ({ uuid, language, displayName, - userBlurb, - imageUrl, + // userBlurb, + // imageUrl, + body, }) { if (SKIP_FLAG_METHODS) { return; @@ -403,11 +404,11 @@ function sendProfileSlurNotification ({ uuid, }); let profileData = `Display Name: ${displayName}`; - if (userBlurb) { - profileData += `\n\n${userBlurb}`; + if (body) { + profileData += `\n\n${body.userBlurb}`; } - if (imageUrl) { - profileData += `\n\n${imageUrl}`; + if (body) { + profileData += `\n\n${body.imageUrl}`; } flagSlack diff --git a/website/server/libs/user/index.js b/website/server/libs/user/index.js index 5e13902e05..03bded50fc 100644 --- a/website/server/libs/user/index.js +++ b/website/server/libs/user/index.js @@ -112,18 +112,17 @@ async function checkNewInputForProfanity (user, res, newValue) { const containsSlur = stringContainsProfanity(newValue, 'slur'); if (containsSlur) { user.flags.chatRevoked = true; - user.flags.chatShadowMuted = true; await user.save(); // slack info for flagged-posts const authorEmail = getUserInfo(user, ['email']).email; slack.sendProfileSlurNotification({ authorEmail, - author: user.username, + author: user.auth.local.username, uuid: user.id, language: user.preferences.language, displayName: user.profile.name, - userBlurb: user.profile.blurb, - imageUrl: user.profile.imageUrl, + userBlurb: res.body, + // imageUrl: res.profile.imageUrl, }); // hard stop error & message throw new BadRequest(res.t('bannedSlurUsedInProfile'));