feat(slur blocker): more refactoring

This commit is contained in:
CuriousMagpie
2023-12-12 13:57:29 -05:00
parent bf953998f4
commit 949dee9b1e
2 changed files with 38 additions and 34 deletions
+5 -5
View File
@@ -230,10 +230,10 @@ function sendProfileFlagNotification ({
if (userComment) {
text += ` and commented: ${userComment}`;
}
let profileData = `Display Name: ${flaggedUser.profile.name}`;
if (flaggedUser.profile.imageUrl) {
profileData += `\n\nImage URL: ${flaggedUser.profile.imageUrl}`;
}
let profileData = `Display Name: ${flaggedUser.profile.displayName}`;
// if (flaggedUser.profile.imageUrl) {
// profileData += `\n\nImage URL: ${flaggedUser.profile.imageUrl}`;
// }
if (flaggedUser.profile.blurb) {
profileData += `\n\nAbout: ${flaggedUser.profile.blurb}`;
}
@@ -246,7 +246,7 @@ function sendProfileFlagNotification ({
color: 'danger',
title,
title_link: titleLink,
text: profileData,
body: profileData,
mrkdwn_in: [
'text',
],
+33 -29
View File
@@ -138,39 +138,43 @@ export async function update (req, res, { isV3 = false }) {
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);
// 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,
});
if (req.body['profile.blurb'] !== undefined) {
const newBlurb = req.body['profile.blurb'];
await checkNewInputForProfanity(user, res, newName);
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: newName,
userBlurb: newBlurb,
// 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['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) {
const groupsToMirror = req.body['preferences.tasks.mirrorGroupTasks'];