feat(profiles/challenges): work on profile block & slack report

This commit is contained in:
CuriousMagpie
2023-12-04 17:25:17 -05:00
parent bdb2e06e5e
commit 8f9822ffe8
2 changed files with 28 additions and 14 deletions
+20 -8
View File
@@ -383,21 +383,32 @@ function sendGroupSlurNotification ({
function sendProfileSlurNotification ({
authorEmail,
author,
message,
uuid,
language,
displayName,
userBlurb,
imageUrl,
}) {
if (SKIP_FLAG_METHODS) {
return;
}
const text = `${author.auth.local.username} (${author._id}) tried to post a slur (${message}.`;
const titleLink = `${BASE_URL}/profile/${author._id}`;
const title = 'User Profile Report: Slur';
const titleLink = `${BASE_URL}/profile/${uuid}`;
const text = `@${author} (${uuid}, ${language}) tried to post a slur in their Profile.`;
const authorName = formatUser({
name: author.auth.local.username,
displayName: author.profile.name,
name: author,
displayName,
email: authorEmail,
uuid: author.id,
uuid,
});
let profileData = `Display Name: ${displayName}`;
if (userBlurb) {
profileData += `\n\n${userBlurb}`;
}
if (imageUrl) {
profileData += `\n\n${imageUrl}`;
}
flagSlack
.send({
@@ -406,8 +417,9 @@ function sendProfileSlurNotification ({
fallback: 'Slur Message',
color: 'danger',
author_name: authorName,
title,
title_link: titleLink,
text: message,
text: profileData,
mrkdwn_in: [
'text',
],
+8 -6
View File
@@ -107,21 +107,23 @@ function checkPreferencePurchase (user, path, item) {
return _.get(user.purchased, itemPath);
}
// checks for banned slurs - swears are allowed & dependent on user flagging
// checks for profile banned slurs - swears are allowed & dependent on user flagging
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 flagged-posts
// slack info for flagged-posts
const authorEmail = getUserInfo(user, ['email']).email;
slack.sendProfileSlurNotification({
authorEmail,
author: user,
message: [user.profile.name,
user.profile.blurb],
image: user.profile.imageUrl,
author: user.username,
uuid: user.id,
language: user.preferences.language,
displayName: user.profile.name,
userBlurb: user.profile.blurb,
imageUrl: user.profile.imageUrl,
});
// hard stop error & message
throw new BadRequest(res.t('bannedSlurUsedInProfile'));