feat(slur/swear): working on it

This commit is contained in:
CuriousMagpie
2023-12-01 16:11:27 -05:00
parent 7277b5cad5
commit bdb2e06e5e
2 changed files with 18 additions and 37 deletions
@@ -240,7 +240,7 @@ api.createChallenge = {
|| (textContainsBannedSlur(req.body.description)))) {
// slack flagged-posts
const authorEmail = getUserInfo(user, ['email']).email;
slack.sendSlurNotification({
slack.sendChallengeSlurNotification({
authorEmail,
author: user,
group,
+17 -36
View File
@@ -416,58 +416,39 @@ function sendProfileSlurNotification ({
.catch(err => logger.error(err, 'Error while sending flag data to Slack.'));
}
function sendPersonalMessageSlurNotification ({
function sendChallengeSlurNotification ({
authorEmail,
author,
message,
flagger,
group,
body,
title,
}) {
if (SKIP_FLAG_METHODS) {
return;
}
const text = `${author.profile.name} (${author._id}) tried to post a slur in ${group},`;
let titleLink;
let text = `${author.profile.name} (${author.id}; language: ${author.preferences.language}) tried to post a slur.`;
const footer = '';
// if (userComment) {
// text += ` and commented: ${userComment}`;
// }
// const messageText = message.text;
// let sender;
// let recipient;
// const messageUserFormat = formatUser({
// displayName: message.user,
// name: message.username,
// email: messageUserEmail,
// uuid: message.uuid,
// });
// if (message.sent) {
// sender = flaggerFormat;
// recipient = messageUserFormat;
// } else {
// sender = messageUserFormat;
// recipient = flaggerFormat;
// }
const authorName = `${sender} wrote this message to ${recipient}.`;
const authorName = formatUser({
name: author.auth.local.username,
displayName: author.profile.name,
email: authorEmail,
uuid: author.id,
});
flagSlack
.send({
text,
attachments: [{
fallback: 'Flag Message',
fallback: 'Slur Message',
color: 'danger',
author_name: authorName,
title,
titleName: title,
title_link: titleLink,
text: messageText,
footer,
text: body,
mrkdwn_in: [
'text',
'body',
],
}],
})
@@ -483,6 +464,6 @@ export {
sendShadowMutedPostNotification,
sendGroupSlurNotification,
sendProfileSlurNotification,
sendPersonalMessageSlurNotification,
sendChallengeSlurNotification,
formatUser,
};