From 8f9822ffe8c820918f1ff59c3fd97faded9ad1f9 Mon Sep 17 00:00:00 2001 From: CuriousMagpie Date: Mon, 4 Dec 2023 17:25:17 -0500 Subject: [PATCH] feat(profiles/challenges): work on profile block & slack report --- website/server/libs/slack.js | 28 ++++++++++++++++++++-------- website/server/libs/user/index.js | 14 ++++++++------ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/website/server/libs/slack.js b/website/server/libs/slack.js index afee5490d6..18816c91f3 100644 --- a/website/server/libs/slack.js +++ b/website/server/libs/slack.js @@ -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', ], diff --git a/website/server/libs/user/index.js b/website/server/libs/user/index.js index c67ffd5fd2..5e13902e05 100644 --- a/website/server/libs/user/index.js +++ b/website/server/libs/user/index.js @@ -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'));