feat(slur/swear blocker): work on Profiles

This commit is contained in:
CuriousMagpie
2023-12-06 12:12:55 -05:00
parent 8f9822ffe8
commit f2db90c494
5 changed files with 30 additions and 29 deletions
+1 -1
View File
@@ -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 Habiticas 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 Habiticas 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",
+18 -17
View File
@@ -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);
+7 -6
View File
@@ -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
+3 -4
View File
@@ -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'));