feat(slur blocker): refactoring code
This commit is contained in:
@@ -269,26 +269,6 @@ api.createChallenge = {
|
||||
throw new BadRequest(res.t('challengeBannedWords'));
|
||||
}
|
||||
|
||||
// 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();
|
||||
// }
|
||||
|
||||
const { savedChal } = await createChallenge(user, req, res);
|
||||
|
||||
await user.save();
|
||||
|
||||
@@ -113,19 +113,7 @@ async function checkNewInputForProfanity (user, res, newValue) {
|
||||
if (containsSlur) {
|
||||
user.flags.chatRevoked = true;
|
||||
await user.save();
|
||||
// slack info for flagged-posts
|
||||
const authorEmail = getUserInfo(user, ['email']).email;
|
||||
slack.sendProfileSlurNotification({
|
||||
authorEmail,
|
||||
author: user.auth.local.username,
|
||||
uuid: user.id,
|
||||
language: user.preferences.language,
|
||||
displayName: user.profile.name,
|
||||
userBlurb: res.body,
|
||||
// imageUrl: res.profile.imageUrl,
|
||||
});
|
||||
// hard stop error & message
|
||||
throw new BadRequest(res.t('bannedSlurUsedInProfile'));
|
||||
// return true; // this makes the function sad and claim it's not returning a value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,11 +139,37 @@ export async function update (req, res, { isV3 = false }) {
|
||||
if (newName.length > 30) throw new BadRequest(res.t('displaynameIssueLength'));
|
||||
if (nameContainsNewline(newName)) throw new BadRequest(res.t('displaynameIssueNewline'));
|
||||
await checkNewInputForProfanity(user, res, newName);
|
||||
// slack info for flagged-posts
|
||||
const authorEmail = getUserInfo(user, ['email']).email;
|
||||
slack.sendProfileSlurNotification({
|
||||
authorEmail,
|
||||
author: user.auth.local.username,
|
||||
uuid: user.id,
|
||||
language: user.preferences.language,
|
||||
displayName: newName,
|
||||
// userBlurb: res.body,
|
||||
// imageUrl: res.profile.imageUrl,
|
||||
});
|
||||
// hard stop error & message
|
||||
throw new BadRequest(res.t('bannedSlurUsedInProfile'));
|
||||
}
|
||||
|
||||
if (req.body['profile.blurb'] !== undefined) {
|
||||
const newBlurb = req.body['profile.blurb'];
|
||||
await checkNewInputForProfanity(user, res, newBlurb);
|
||||
// slack info for flagged-posts
|
||||
const authorEmail = getUserInfo(user, ['email']).email;
|
||||
slack.sendProfileSlurNotification({
|
||||
authorEmail,
|
||||
author: user.auth.local.username,
|
||||
uuid: user.id,
|
||||
language: user.preferences.language,
|
||||
displayName: user.profile.name,
|
||||
userBlurb: newBlurb,
|
||||
// imageUrl: res.profile.imageUrl,
|
||||
});
|
||||
// hard stop error & message
|
||||
throw new BadRequest(res.t('bannedSlurUsedInProfile'));
|
||||
}
|
||||
|
||||
if (req.body['preferences.tasks.mirrorGroupTasks'] !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user