mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
feat(challenges): more slur blocker
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
"communityGuidelines": "Community Guidelines",
|
"communityGuidelines": "Community Guidelines",
|
||||||
"bannedWordUsed": "Oops! Looks like this post contains a swearword 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.",
|
"bannedWordUsed": "Oops! Looks like this post contains a swearword 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.",
|
"bannedSlurUsed": "Your post contained inappropriate language, and your chat privileges have been revoked.",
|
||||||
|
"challengeBannedWordsAndSlurs": "Your challenge contains either a swear word or other inappropriate language. Please remove in order to continue with your challenge creation.",
|
||||||
"party": "Party",
|
"party": "Party",
|
||||||
"usernameCopied": "Username copied to clipboard.",
|
"usernameCopied": "Username copied to clipboard.",
|
||||||
"create": "Create",
|
"create": "Create",
|
||||||
|
|||||||
@@ -225,7 +225,18 @@ api.createChallenge = {
|
|||||||
const validationErrors = req.validationErrors();
|
const validationErrors = req.validationErrors();
|
||||||
if (validationErrors) throw validationErrors;
|
if (validationErrors) throw validationErrors;
|
||||||
|
|
||||||
const { savedChal, group } = await createChallenge(user, req, res);
|
const { group } = (user, req, req);
|
||||||
|
|
||||||
|
// 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)))) {
|
||||||
|
throw new BadRequest(res.t('challengeBannedWordsAndSlurs'));
|
||||||
|
}
|
||||||
|
|
||||||
|
const { savedChal } = await createChallenge(user, req, res);
|
||||||
|
|
||||||
const response = savedChal.toJSON();
|
const response = savedChal.toJSON();
|
||||||
response.leader = { // the leader is the authenticated user
|
response.leader = { // the leader is the authenticated user
|
||||||
@@ -246,55 +257,6 @@ api.createChallenge = {
|
|||||||
headers: req.headers,
|
headers: req.headers,
|
||||||
});
|
});
|
||||||
|
|
||||||
// check challenge for slurs
|
|
||||||
if (group.privacy === 'public'
|
|
||||||
&& ((textContainsBannedSlur(req.body.name))
|
|
||||||
|| (textContainsBannedSlur(req.body.shortName))
|
|
||||||
|| (textContainsBannedSlur(req.body.summary))
|
|
||||||
|| (textContainsBannedSlur(req.body.description)))) {
|
|
||||||
const { message } = req.body.name
|
|
||||||
&& req.body.shortName
|
|
||||||
&& req.body.summary
|
|
||||||
&& req.body.description;
|
|
||||||
user.flags.chatRevoked = true;
|
|
||||||
await user.save();
|
|
||||||
// note to Natalie:
|
|
||||||
// does this need to shadow-mute the user? And what about hiding the challenge
|
|
||||||
// until the language can be corrected?
|
|
||||||
|
|
||||||
// email mods
|
|
||||||
const authorEmail = getUserInfo(user, ['email']).email;
|
|
||||||
|
|
||||||
// send Slack message
|
|
||||||
slack.sendSlurNotification({
|
|
||||||
authorEmail,
|
|
||||||
author: user,
|
|
||||||
group,
|
|
||||||
message,
|
|
||||||
});
|
|
||||||
|
|
||||||
throw new BadRequest(res.t('bannedSlurUsed'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// prevent banned words being posted, except in private challenges
|
|
||||||
if (group.privacy === 'public' && textContainsBannedWord(req.body.name)) {
|
|
||||||
const { message } = req.body;
|
|
||||||
await user.save();
|
|
||||||
|
|
||||||
// email mods
|
|
||||||
const authorEmail = getUserInfo(user, ['email']).email;
|
|
||||||
|
|
||||||
// send Slack message
|
|
||||||
slack.sendSlurNotification({
|
|
||||||
authorEmail,
|
|
||||||
author: user,
|
|
||||||
group,
|
|
||||||
message,
|
|
||||||
});
|
|
||||||
|
|
||||||
throw new BadRequest(res.t('bannedWordUsed'));
|
|
||||||
}
|
|
||||||
|
|
||||||
res.respond(201, response);
|
res.respond(201, response);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user