2016-08-27 03:12:23 +00:00
/* eslint-disable camelcase */
import { IncomingWebhook } from '@slack/client' ;
2016-08-27 04:09:54 +00:00
import logger from './logger' ;
2016-08-27 03:12:23 +00:00
import { TAVERN _ID } from '../models/group' ;
import nconf from 'nconf' ;
2018-06-15 09:01:10 +00:00
import moment from 'moment' ;
2016-08-27 03:12:23 +00:00
2018-12-06 16:13:49 +00:00
const SLACK _FLAGGING _URL = nconf . get ( 'SLACK_FLAGGING_URL' ) ;
const SLACK _FLAGGING _FOOTER _LINK = nconf . get ( 'SLACK_FLAGGING_FOOTER_LINK' ) ;
const SLACK _SUBSCRIPTIONS _URL = nconf . get ( 'SLACK_SUBSCRIPTIONS_URL' ) ;
2016-08-27 03:12:23 +00:00
const BASE _URL = nconf . get ( 'BASE_URL' ) ;
2018-06-02 16:14:53 +00:00
const IS _PRODUCTION = nconf . get ( 'IS_PROD' ) ;
const SKIP _FLAG _METHODS = IS _PRODUCTION && ! SLACK _FLAGGING _URL ;
const SKIP _SUB _METHOD = IS _PRODUCTION && ! SLACK _SUBSCRIPTIONS _URL ;
2016-08-27 03:12:23 +00:00
2016-08-27 04:09:54 +00:00
let flagSlack ;
2016-12-09 02:08:56 +00:00
let subscriptionSlack ;
2016-08-27 04:09:54 +00:00
try {
flagSlack = new IncomingWebhook ( SLACK _FLAGGING _URL ) ;
2016-12-09 02:08:56 +00:00
subscriptionSlack = new IncomingWebhook ( SLACK _SUBSCRIPTIONS _URL ) ;
2016-08-27 04:09:54 +00:00
} catch ( err ) {
logger . error ( err ) ;
2018-06-02 16:14:53 +00:00
if ( ! IS _PRODUCTION ) {
flagSlack = subscriptionSlack = {
send ( data ) {
logger . info ( 'Data sent to slack' , data ) ;
} ,
} ;
}
2016-08-27 04:09:54 +00:00
}
2016-08-27 03:12:23 +00:00
2018-11-29 19:15:47 +00:00
/ * *
*
* @ param formatObj . name userName
* @ param formatObj . displayName displayName
* @ param formatObj . email email
* @ param formatObj . uuid uuid
* @ returns { string }
* /
function formatUser ( formatObj ) {
2019-01-27 18:05:00 +00:00
return ` @ ${ formatObj . name } ${ formatObj . displayName } ( ${ formatObj . email } ; ${ formatObj . uuid } ) ` ;
2018-11-29 19:15:47 +00:00
}
2016-08-27 03:12:23 +00:00
function sendFlagNotification ( {
2016-09-30 12:42:51 +00:00
authorEmail ,
2016-08-27 03:12:23 +00:00
flagger ,
group ,
message ,
2018-03-14 12:41:13 +00:00
userComment ,
2018-08-03 10:04:01 +00:00
automatedComment ,
2016-08-27 03:12:23 +00:00
} ) {
2018-06-02 16:14:53 +00:00
if ( SKIP _FLAG _METHODS ) {
2016-08-27 04:09:54 +00:00
return ;
}
2016-08-27 03:12:23 +00:00
let titleLink ;
2016-09-02 20:23:56 +00:00
let authorName ;
2016-08-27 03:12:23 +00:00
let title = ` Flag in ${ group . name } ` ;
2018-06-02 17:27:28 +00:00
let text = ` ${ flagger . profile . name } ( ${ flagger . id } ; language: ${ flagger . preferences . language } ) flagged a group message ` ;
2018-08-03 10:04:01 +00:00
let footer = ` < ${ SLACK _FLAGGING _FOOTER _LINK } ?groupId= ${ group . id } &chatId= ${ message . id } |Flag this message.> ` ;
2016-08-27 03:12:23 +00:00
2018-03-14 12:41:13 +00:00
if ( userComment ) {
text += ` and commented: ${ userComment } ` ;
}
2018-08-03 10:04:01 +00:00
if ( automatedComment ) {
footer += ` ${ automatedComment } ` ;
}
2018-03-14 12:41:13 +00:00
2016-08-27 03:12:23 +00:00
if ( group . id === TAVERN _ID ) {
2017-09-16 12:19:07 +00:00
titleLink = ` ${ BASE _URL } /groups/tavern ` ;
2016-08-27 03:12:23 +00:00
} else if ( group . privacy === 'public' ) {
2017-09-16 12:19:07 +00:00
titleLink = ` ${ BASE _URL } /groups/guild/ ${ group . id } ` ;
2016-08-27 03:12:23 +00:00
} else {
title += ` - ( ${ group . privacy } ${ group . type } ) ` ;
}
2016-09-02 20:23:56 +00:00
if ( ! message . user && message . uuid === 'system' ) {
authorName = 'System Message' ;
} else {
2018-11-29 19:15:47 +00:00
authorName = formatUser ( {
name : message . username ,
displayName : message . user ,
email : authorEmail ,
uuid : message . uuid ,
} ) ;
2016-09-02 20:23:56 +00:00
}
2018-06-15 09:01:10 +00:00
const timestamp = ` ${ moment ( message . timestamp ) . utc ( ) . format ( 'YYYY-MM-DD HH:mm' ) } UTC ` ;
2016-08-27 03:12:23 +00:00
flagSlack . send ( {
text ,
attachments : [ {
fallback : 'Flag Message' ,
color : 'danger' ,
2018-06-15 09:01:10 +00:00
author _name : ` ${ authorName } \n ${ timestamp } ` ,
2016-08-27 03:12:23 +00:00
title ,
title _link : titleLink ,
text : message . text ,
2018-08-03 10:04:01 +00:00
footer ,
2016-08-27 03:12:23 +00:00
mrkdwn _in : [
'text' ,
] ,
} ] ,
} ) ;
}
2018-06-02 17:27:28 +00:00
function sendInboxFlagNotification ( {
authorEmail ,
flagger ,
message ,
userComment ,
} ) {
if ( SKIP _FLAG _METHODS ) {
return ;
}
2018-11-29 19:15:47 +00:00
let titleLink = '' ;
2018-06-02 17:27:28 +00:00
let authorName ;
let title = ` Flag in ${ flagger . profile . name } 's Inbox ` ;
let text = ` ${ flagger . profile . name } ( ${ flagger . id } ; language: ${ flagger . preferences . language } ) flagged a PM ` ;
2018-10-08 17:08:14 +00:00
let footer = '' ;
2018-06-02 17:27:28 +00:00
if ( userComment ) {
text += ` and commented: ${ userComment } ` ;
}
let messageText = message . text ;
2018-10-10 18:46:43 +00:00
let sender = '' ;
let recipient = '' ;
2018-06-02 17:27:28 +00:00
2018-11-29 19:15:47 +00:00
const flaggerFormat = formatUser ( {
displayName : flagger . profile . name ,
name : flagger . auth . local . username ,
email : flagger . auth . local . email ,
uuid : flagger . _id ,
} ) ;
const messageUserFormat = formatUser ( {
displayName : message . user ,
name : message . username ,
email : authorEmail ,
uuid : message . uuid ,
} ) ;
2018-10-10 18:46:43 +00:00
if ( message . sent ) {
sender = flaggerFormat ;
recipient = messageUserFormat ;
2018-06-02 17:27:28 +00:00
} else {
2018-10-10 18:46:43 +00:00
sender = messageUserFormat ;
recipient = flaggerFormat ;
2018-06-02 17:27:28 +00:00
}
2018-11-29 18:01:26 +00:00
authorName = ` ${ sender } wrote this message to ${ recipient } . ` ;
2018-10-10 18:46:43 +00:00
2018-06-02 17:27:28 +00:00
flagSlack . send ( {
text ,
attachments : [ {
fallback : 'Flag Message' ,
color : 'danger' ,
author _name : authorName ,
title ,
title _link : titleLink ,
text : messageText ,
2018-09-22 17:18:08 +00:00
footer ,
2018-06-02 17:27:28 +00:00
mrkdwn _in : [
'text' ,
] ,
} ] ,
} ) ;
}
2016-12-09 02:08:56 +00:00
function sendSubscriptionNotification ( {
buyer ,
recipient ,
paymentMethod ,
months ,
2017-03-10 01:11:21 +00:00
groupId ,
2016-12-09 02:08:56 +00:00
} ) {
2018-06-02 16:14:53 +00:00
if ( SKIP _SUB _METHOD ) {
2016-12-09 02:08:56 +00:00
return ;
}
let text ;
let timestamp = new Date ( ) ;
2017-01-07 15:42:03 +00:00
if ( recipient . id ) {
2018-01-12 21:15:42 +00:00
text = ` ${ buyer . name } ${ buyer . id } ${ buyer . email } bought a ${ months } -month gift subscription for ${ recipient . name } ${ recipient . id } ${ recipient . email } using ${ paymentMethod } on ${ timestamp } ` ;
2017-03-10 01:11:21 +00:00
} else if ( groupId ) {
text = ` ${ buyer . name } ${ buyer . id } ${ buyer . email } bought a 1-month recurring group-plan for ${ groupId } using ${ paymentMethod } on ${ timestamp } ` ;
2016-12-09 02:08:56 +00:00
} else {
2017-01-07 15:42:03 +00:00
text = ` ${ buyer . name } ${ buyer . id } ${ buyer . email } bought a ${ months } -month recurring subscription using ${ paymentMethod } on ${ timestamp } ` ;
2016-12-09 02:08:56 +00:00
}
subscriptionSlack . send ( {
text ,
} ) ;
}
Automatically mute users who attempt to post a slur, fixes #8062 (#8177)
* Initial psuedo-code for checking for slurs in messages
* Initial working prototype for blocking posting of slurs. Moved check from group.js to the chat api. Still needs: to permanently revoke chat privileges, to notify the moderators, a better method for checking for the blacklisted words, and a way to get the real list of words to check.
* Permanently revoke chat privileges when attempting to post a slur.
* Removed console logs
* Fixing rebase
* Do not moderate private groups
* Moved slur check to a generic check for banned words function
* Moved list of slurs to a separate file, fixed misplacement of return in ContainsBannedWords() function
* Slurs are blocked in both public and private groups
* Added code to send a slack message for slurs
* Fixed formatting issues
* Incorporated tectContainsBannedWords() function from PR 8197, added an argument to specify the list of banned words to check
* Added initial tests for blocking slurs and revoking chat priviliges
* Uncommented line to save revoked privileges
* Check that privileges are revoked in private groups
* Moved code to email/slack mods to chat api file
* Switched to BadRequest instead of NotFound error
* Restore chat privileges after test
* Using official placeholder slur
* Fixed line to export sendSubscriptionNotification function for slack
* Replaced muteUser function in user methods with a single line in the chat controller file
* Reset chatRevoked flag to false in a single line
* Switched method of setting chatRevoked flag so that it is updated locally and in the database
* First attempt at the muteUser function: revokes user's chat privileges and notifies moderators
* Manual merge for cherry-pick
* Initial working prototype for blocking posting of slurs. Moved check from group.js to the chat api. Still needs: to permanently revoke chat privileges, to notify the moderators, a better method for checking for the blacklisted words, and a way to get the real list of words to check.
* Permanently revoke chat privileges when attempting to post a slur.
* Removed console logs
* Created report to be sent to moderators via email
* Do not moderate private groups
* Moved slur check to a generic check for banned words function
* Moved list of slurs to a separate file, fixed misplacement of return in ContainsBannedWords() function
* Slurs are blocked in both public and private groups
* Added code to send a slack message for slurs
* Fixed formatting issues
* Incorporated tectContainsBannedWords() function from PR 8197, added an argument to specify the list of banned words to check
* Added initial tests for blocking slurs and revoking chat priviliges
* Uncommented line to save revoked privileges
* Check that privileges are revoked in private groups
* Moved code to email/slack mods to chat api file
* Switched to BadRequest instead of NotFound error
* Restore chat privileges after test
* Using official placeholder slur
* Fixed line to export sendSubscriptionNotification function for slack
* Replaced muteUser function in user methods with a single line in the chat controller file
* Reset chatRevoked flag to false in a single line
* Switched method of setting chatRevoked flag so that it is updated locally and in the database
* Removed some code that got re-added after rebase
* Tests for automatic slur muting pass but are incomplete (do not check that chatRevoked flag is true)
* Moved list of banned slurs to server side
* Added warning to bannedSlurs file
* Test chat privileges revoked when posting slur in public chat
* Fix issues left over after rebase (I hope)
* Added code to test for revoked chat privileges after posting a slur in a private group
* Moved banned slur message into locales message
* Added new code to check for banned slurs (parallels banned words code)
* Fixed AUTHOR_MOTAL_URL in sendTxn for slur blocking
* Added tests that email sent on attempted slur in chat post
* Created context for slur-related-tests, fixed sandboxing of email. Successfully tests that email.sendTxn is called, but the email content test fails
* commented out slack (for now) and cleaned up tests of sending email
* Successfully tests that slur-report-to-mods email is sent
* Slack message is sent, and testing works, but some user variables seem to only work when found in chat.js and passed to slack
* Made some fixes for lint, but not sure what to do about the camel case requirement fail, since that's how they're defined in other slack calls
* Slack tests pass, skipped camelcase check around those code blocks
* Fixed InternalServerError caused by slack messaging
* Updated chat privileges revoked error
* fix(locale): typo correction
2017-07-19 21:06:15 +00:00
function sendSlurNotification ( {
authorEmail ,
author ,
group ,
message ,
} ) {
2018-06-02 16:14:53 +00:00
if ( SKIP _FLAG _METHODS ) {
Automatically mute users who attempt to post a slur, fixes #8062 (#8177)
* Initial psuedo-code for checking for slurs in messages
* Initial working prototype for blocking posting of slurs. Moved check from group.js to the chat api. Still needs: to permanently revoke chat privileges, to notify the moderators, a better method for checking for the blacklisted words, and a way to get the real list of words to check.
* Permanently revoke chat privileges when attempting to post a slur.
* Removed console logs
* Fixing rebase
* Do not moderate private groups
* Moved slur check to a generic check for banned words function
* Moved list of slurs to a separate file, fixed misplacement of return in ContainsBannedWords() function
* Slurs are blocked in both public and private groups
* Added code to send a slack message for slurs
* Fixed formatting issues
* Incorporated tectContainsBannedWords() function from PR 8197, added an argument to specify the list of banned words to check
* Added initial tests for blocking slurs and revoking chat priviliges
* Uncommented line to save revoked privileges
* Check that privileges are revoked in private groups
* Moved code to email/slack mods to chat api file
* Switched to BadRequest instead of NotFound error
* Restore chat privileges after test
* Using official placeholder slur
* Fixed line to export sendSubscriptionNotification function for slack
* Replaced muteUser function in user methods with a single line in the chat controller file
* Reset chatRevoked flag to false in a single line
* Switched method of setting chatRevoked flag so that it is updated locally and in the database
* First attempt at the muteUser function: revokes user's chat privileges and notifies moderators
* Manual merge for cherry-pick
* Initial working prototype for blocking posting of slurs. Moved check from group.js to the chat api. Still needs: to permanently revoke chat privileges, to notify the moderators, a better method for checking for the blacklisted words, and a way to get the real list of words to check.
* Permanently revoke chat privileges when attempting to post a slur.
* Removed console logs
* Created report to be sent to moderators via email
* Do not moderate private groups
* Moved slur check to a generic check for banned words function
* Moved list of slurs to a separate file, fixed misplacement of return in ContainsBannedWords() function
* Slurs are blocked in both public and private groups
* Added code to send a slack message for slurs
* Fixed formatting issues
* Incorporated tectContainsBannedWords() function from PR 8197, added an argument to specify the list of banned words to check
* Added initial tests for blocking slurs and revoking chat priviliges
* Uncommented line to save revoked privileges
* Check that privileges are revoked in private groups
* Moved code to email/slack mods to chat api file
* Switched to BadRequest instead of NotFound error
* Restore chat privileges after test
* Using official placeholder slur
* Fixed line to export sendSubscriptionNotification function for slack
* Replaced muteUser function in user methods with a single line in the chat controller file
* Reset chatRevoked flag to false in a single line
* Switched method of setting chatRevoked flag so that it is updated locally and in the database
* Removed some code that got re-added after rebase
* Tests for automatic slur muting pass but are incomplete (do not check that chatRevoked flag is true)
* Moved list of banned slurs to server side
* Added warning to bannedSlurs file
* Test chat privileges revoked when posting slur in public chat
* Fix issues left over after rebase (I hope)
* Added code to test for revoked chat privileges after posting a slur in a private group
* Moved banned slur message into locales message
* Added new code to check for banned slurs (parallels banned words code)
* Fixed AUTHOR_MOTAL_URL in sendTxn for slur blocking
* Added tests that email sent on attempted slur in chat post
* Created context for slur-related-tests, fixed sandboxing of email. Successfully tests that email.sendTxn is called, but the email content test fails
* commented out slack (for now) and cleaned up tests of sending email
* Successfully tests that slur-report-to-mods email is sent
* Slack message is sent, and testing works, but some user variables seem to only work when found in chat.js and passed to slack
* Made some fixes for lint, but not sure what to do about the camel case requirement fail, since that's how they're defined in other slack calls
* Slack tests pass, skipped camelcase check around those code blocks
* Fixed InternalServerError caused by slack messaging
* Updated chat privileges revoked error
* fix(locale): typo correction
2017-07-19 21:06:15 +00:00
return ;
}
let titleLink ;
let authorName ;
let title = ` Slur in ${ group . name } ` ;
let text = ` ${ author . profile . name } ( ${ author . _id } ) tried to post a slur ` ;
if ( group . id === TAVERN _ID ) {
2017-09-16 12:19:07 +00:00
titleLink = ` ${ BASE _URL } /groups/tavern ` ;
Automatically mute users who attempt to post a slur, fixes #8062 (#8177)
* Initial psuedo-code for checking for slurs in messages
* Initial working prototype for blocking posting of slurs. Moved check from group.js to the chat api. Still needs: to permanently revoke chat privileges, to notify the moderators, a better method for checking for the blacklisted words, and a way to get the real list of words to check.
* Permanently revoke chat privileges when attempting to post a slur.
* Removed console logs
* Fixing rebase
* Do not moderate private groups
* Moved slur check to a generic check for banned words function
* Moved list of slurs to a separate file, fixed misplacement of return in ContainsBannedWords() function
* Slurs are blocked in both public and private groups
* Added code to send a slack message for slurs
* Fixed formatting issues
* Incorporated tectContainsBannedWords() function from PR 8197, added an argument to specify the list of banned words to check
* Added initial tests for blocking slurs and revoking chat priviliges
* Uncommented line to save revoked privileges
* Check that privileges are revoked in private groups
* Moved code to email/slack mods to chat api file
* Switched to BadRequest instead of NotFound error
* Restore chat privileges after test
* Using official placeholder slur
* Fixed line to export sendSubscriptionNotification function for slack
* Replaced muteUser function in user methods with a single line in the chat controller file
* Reset chatRevoked flag to false in a single line
* Switched method of setting chatRevoked flag so that it is updated locally and in the database
* First attempt at the muteUser function: revokes user's chat privileges and notifies moderators
* Manual merge for cherry-pick
* Initial working prototype for blocking posting of slurs. Moved check from group.js to the chat api. Still needs: to permanently revoke chat privileges, to notify the moderators, a better method for checking for the blacklisted words, and a way to get the real list of words to check.
* Permanently revoke chat privileges when attempting to post a slur.
* Removed console logs
* Created report to be sent to moderators via email
* Do not moderate private groups
* Moved slur check to a generic check for banned words function
* Moved list of slurs to a separate file, fixed misplacement of return in ContainsBannedWords() function
* Slurs are blocked in both public and private groups
* Added code to send a slack message for slurs
* Fixed formatting issues
* Incorporated tectContainsBannedWords() function from PR 8197, added an argument to specify the list of banned words to check
* Added initial tests for blocking slurs and revoking chat priviliges
* Uncommented line to save revoked privileges
* Check that privileges are revoked in private groups
* Moved code to email/slack mods to chat api file
* Switched to BadRequest instead of NotFound error
* Restore chat privileges after test
* Using official placeholder slur
* Fixed line to export sendSubscriptionNotification function for slack
* Replaced muteUser function in user methods with a single line in the chat controller file
* Reset chatRevoked flag to false in a single line
* Switched method of setting chatRevoked flag so that it is updated locally and in the database
* Removed some code that got re-added after rebase
* Tests for automatic slur muting pass but are incomplete (do not check that chatRevoked flag is true)
* Moved list of banned slurs to server side
* Added warning to bannedSlurs file
* Test chat privileges revoked when posting slur in public chat
* Fix issues left over after rebase (I hope)
* Added code to test for revoked chat privileges after posting a slur in a private group
* Moved banned slur message into locales message
* Added new code to check for banned slurs (parallels banned words code)
* Fixed AUTHOR_MOTAL_URL in sendTxn for slur blocking
* Added tests that email sent on attempted slur in chat post
* Created context for slur-related-tests, fixed sandboxing of email. Successfully tests that email.sendTxn is called, but the email content test fails
* commented out slack (for now) and cleaned up tests of sending email
* Successfully tests that slur-report-to-mods email is sent
* Slack message is sent, and testing works, but some user variables seem to only work when found in chat.js and passed to slack
* Made some fixes for lint, but not sure what to do about the camel case requirement fail, since that's how they're defined in other slack calls
* Slack tests pass, skipped camelcase check around those code blocks
* Fixed InternalServerError caused by slack messaging
* Updated chat privileges revoked error
* fix(locale): typo correction
2017-07-19 21:06:15 +00:00
} else if ( group . privacy === 'public' ) {
2017-09-16 12:19:07 +00:00
titleLink = ` ${ BASE _URL } /groups/guild/ ${ group . id } ` ;
Automatically mute users who attempt to post a slur, fixes #8062 (#8177)
* Initial psuedo-code for checking for slurs in messages
* Initial working prototype for blocking posting of slurs. Moved check from group.js to the chat api. Still needs: to permanently revoke chat privileges, to notify the moderators, a better method for checking for the blacklisted words, and a way to get the real list of words to check.
* Permanently revoke chat privileges when attempting to post a slur.
* Removed console logs
* Fixing rebase
* Do not moderate private groups
* Moved slur check to a generic check for banned words function
* Moved list of slurs to a separate file, fixed misplacement of return in ContainsBannedWords() function
* Slurs are blocked in both public and private groups
* Added code to send a slack message for slurs
* Fixed formatting issues
* Incorporated tectContainsBannedWords() function from PR 8197, added an argument to specify the list of banned words to check
* Added initial tests for blocking slurs and revoking chat priviliges
* Uncommented line to save revoked privileges
* Check that privileges are revoked in private groups
* Moved code to email/slack mods to chat api file
* Switched to BadRequest instead of NotFound error
* Restore chat privileges after test
* Using official placeholder slur
* Fixed line to export sendSubscriptionNotification function for slack
* Replaced muteUser function in user methods with a single line in the chat controller file
* Reset chatRevoked flag to false in a single line
* Switched method of setting chatRevoked flag so that it is updated locally and in the database
* First attempt at the muteUser function: revokes user's chat privileges and notifies moderators
* Manual merge for cherry-pick
* Initial working prototype for blocking posting of slurs. Moved check from group.js to the chat api. Still needs: to permanently revoke chat privileges, to notify the moderators, a better method for checking for the blacklisted words, and a way to get the real list of words to check.
* Permanently revoke chat privileges when attempting to post a slur.
* Removed console logs
* Created report to be sent to moderators via email
* Do not moderate private groups
* Moved slur check to a generic check for banned words function
* Moved list of slurs to a separate file, fixed misplacement of return in ContainsBannedWords() function
* Slurs are blocked in both public and private groups
* Added code to send a slack message for slurs
* Fixed formatting issues
* Incorporated tectContainsBannedWords() function from PR 8197, added an argument to specify the list of banned words to check
* Added initial tests for blocking slurs and revoking chat priviliges
* Uncommented line to save revoked privileges
* Check that privileges are revoked in private groups
* Moved code to email/slack mods to chat api file
* Switched to BadRequest instead of NotFound error
* Restore chat privileges after test
* Using official placeholder slur
* Fixed line to export sendSubscriptionNotification function for slack
* Replaced muteUser function in user methods with a single line in the chat controller file
* Reset chatRevoked flag to false in a single line
* Switched method of setting chatRevoked flag so that it is updated locally and in the database
* Removed some code that got re-added after rebase
* Tests for automatic slur muting pass but are incomplete (do not check that chatRevoked flag is true)
* Moved list of banned slurs to server side
* Added warning to bannedSlurs file
* Test chat privileges revoked when posting slur in public chat
* Fix issues left over after rebase (I hope)
* Added code to test for revoked chat privileges after posting a slur in a private group
* Moved banned slur message into locales message
* Added new code to check for banned slurs (parallels banned words code)
* Fixed AUTHOR_MOTAL_URL in sendTxn for slur blocking
* Added tests that email sent on attempted slur in chat post
* Created context for slur-related-tests, fixed sandboxing of email. Successfully tests that email.sendTxn is called, but the email content test fails
* commented out slack (for now) and cleaned up tests of sending email
* Successfully tests that slur-report-to-mods email is sent
* Slack message is sent, and testing works, but some user variables seem to only work when found in chat.js and passed to slack
* Made some fixes for lint, but not sure what to do about the camel case requirement fail, since that's how they're defined in other slack calls
* Slack tests pass, skipped camelcase check around those code blocks
* Fixed InternalServerError caused by slack messaging
* Updated chat privileges revoked error
* fix(locale): typo correction
2017-07-19 21:06:15 +00:00
} else {
title += ` - ( ${ group . privacy } ${ group . type } ) ` ;
}
2018-11-29 19:15:47 +00:00
authorName = formatUser ( {
name : author . auth . local . username ,
displayName : author . profile . name ,
email : authorEmail ,
uuid : author . id ,
} ) ;
Automatically mute users who attempt to post a slur, fixes #8062 (#8177)
* Initial psuedo-code for checking for slurs in messages
* Initial working prototype for blocking posting of slurs. Moved check from group.js to the chat api. Still needs: to permanently revoke chat privileges, to notify the moderators, a better method for checking for the blacklisted words, and a way to get the real list of words to check.
* Permanently revoke chat privileges when attempting to post a slur.
* Removed console logs
* Fixing rebase
* Do not moderate private groups
* Moved slur check to a generic check for banned words function
* Moved list of slurs to a separate file, fixed misplacement of return in ContainsBannedWords() function
* Slurs are blocked in both public and private groups
* Added code to send a slack message for slurs
* Fixed formatting issues
* Incorporated tectContainsBannedWords() function from PR 8197, added an argument to specify the list of banned words to check
* Added initial tests for blocking slurs and revoking chat priviliges
* Uncommented line to save revoked privileges
* Check that privileges are revoked in private groups
* Moved code to email/slack mods to chat api file
* Switched to BadRequest instead of NotFound error
* Restore chat privileges after test
* Using official placeholder slur
* Fixed line to export sendSubscriptionNotification function for slack
* Replaced muteUser function in user methods with a single line in the chat controller file
* Reset chatRevoked flag to false in a single line
* Switched method of setting chatRevoked flag so that it is updated locally and in the database
* First attempt at the muteUser function: revokes user's chat privileges and notifies moderators
* Manual merge for cherry-pick
* Initial working prototype for blocking posting of slurs. Moved check from group.js to the chat api. Still needs: to permanently revoke chat privileges, to notify the moderators, a better method for checking for the blacklisted words, and a way to get the real list of words to check.
* Permanently revoke chat privileges when attempting to post a slur.
* Removed console logs
* Created report to be sent to moderators via email
* Do not moderate private groups
* Moved slur check to a generic check for banned words function
* Moved list of slurs to a separate file, fixed misplacement of return in ContainsBannedWords() function
* Slurs are blocked in both public and private groups
* Added code to send a slack message for slurs
* Fixed formatting issues
* Incorporated tectContainsBannedWords() function from PR 8197, added an argument to specify the list of banned words to check
* Added initial tests for blocking slurs and revoking chat priviliges
* Uncommented line to save revoked privileges
* Check that privileges are revoked in private groups
* Moved code to email/slack mods to chat api file
* Switched to BadRequest instead of NotFound error
* Restore chat privileges after test
* Using official placeholder slur
* Fixed line to export sendSubscriptionNotification function for slack
* Replaced muteUser function in user methods with a single line in the chat controller file
* Reset chatRevoked flag to false in a single line
* Switched method of setting chatRevoked flag so that it is updated locally and in the database
* Removed some code that got re-added after rebase
* Tests for automatic slur muting pass but are incomplete (do not check that chatRevoked flag is true)
* Moved list of banned slurs to server side
* Added warning to bannedSlurs file
* Test chat privileges revoked when posting slur in public chat
* Fix issues left over after rebase (I hope)
* Added code to test for revoked chat privileges after posting a slur in a private group
* Moved banned slur message into locales message
* Added new code to check for banned slurs (parallels banned words code)
* Fixed AUTHOR_MOTAL_URL in sendTxn for slur blocking
* Added tests that email sent on attempted slur in chat post
* Created context for slur-related-tests, fixed sandboxing of email. Successfully tests that email.sendTxn is called, but the email content test fails
* commented out slack (for now) and cleaned up tests of sending email
* Successfully tests that slur-report-to-mods email is sent
* Slack message is sent, and testing works, but some user variables seem to only work when found in chat.js and passed to slack
* Made some fixes for lint, but not sure what to do about the camel case requirement fail, since that's how they're defined in other slack calls
* Slack tests pass, skipped camelcase check around those code blocks
* Fixed InternalServerError caused by slack messaging
* Updated chat privileges revoked error
* fix(locale): typo correction
2017-07-19 21:06:15 +00:00
flagSlack . send ( {
text ,
attachments : [ {
fallback : 'Slur Message' ,
color : 'danger' ,
author _name : authorName ,
title ,
title _link : titleLink ,
text : message ,
mrkdwn _in : [
'text' ,
] ,
} ] ,
} ) ;
}
module . exports = {
2018-06-02 16:14:53 +00:00
sendFlagNotification ,
2018-06-02 17:27:28 +00:00
sendInboxFlagNotification ,
2018-06-02 16:14:53 +00:00
sendSubscriptionNotification ,
sendSlurNotification ,
2018-11-29 19:15:47 +00:00
formatUser ,
Automatically mute users who attempt to post a slur, fixes #8062 (#8177)
* Initial psuedo-code for checking for slurs in messages
* Initial working prototype for blocking posting of slurs. Moved check from group.js to the chat api. Still needs: to permanently revoke chat privileges, to notify the moderators, a better method for checking for the blacklisted words, and a way to get the real list of words to check.
* Permanently revoke chat privileges when attempting to post a slur.
* Removed console logs
* Fixing rebase
* Do not moderate private groups
* Moved slur check to a generic check for banned words function
* Moved list of slurs to a separate file, fixed misplacement of return in ContainsBannedWords() function
* Slurs are blocked in both public and private groups
* Added code to send a slack message for slurs
* Fixed formatting issues
* Incorporated tectContainsBannedWords() function from PR 8197, added an argument to specify the list of banned words to check
* Added initial tests for blocking slurs and revoking chat priviliges
* Uncommented line to save revoked privileges
* Check that privileges are revoked in private groups
* Moved code to email/slack mods to chat api file
* Switched to BadRequest instead of NotFound error
* Restore chat privileges after test
* Using official placeholder slur
* Fixed line to export sendSubscriptionNotification function for slack
* Replaced muteUser function in user methods with a single line in the chat controller file
* Reset chatRevoked flag to false in a single line
* Switched method of setting chatRevoked flag so that it is updated locally and in the database
* First attempt at the muteUser function: revokes user's chat privileges and notifies moderators
* Manual merge for cherry-pick
* Initial working prototype for blocking posting of slurs. Moved check from group.js to the chat api. Still needs: to permanently revoke chat privileges, to notify the moderators, a better method for checking for the blacklisted words, and a way to get the real list of words to check.
* Permanently revoke chat privileges when attempting to post a slur.
* Removed console logs
* Created report to be sent to moderators via email
* Do not moderate private groups
* Moved slur check to a generic check for banned words function
* Moved list of slurs to a separate file, fixed misplacement of return in ContainsBannedWords() function
* Slurs are blocked in both public and private groups
* Added code to send a slack message for slurs
* Fixed formatting issues
* Incorporated tectContainsBannedWords() function from PR 8197, added an argument to specify the list of banned words to check
* Added initial tests for blocking slurs and revoking chat priviliges
* Uncommented line to save revoked privileges
* Check that privileges are revoked in private groups
* Moved code to email/slack mods to chat api file
* Switched to BadRequest instead of NotFound error
* Restore chat privileges after test
* Using official placeholder slur
* Fixed line to export sendSubscriptionNotification function for slack
* Replaced muteUser function in user methods with a single line in the chat controller file
* Reset chatRevoked flag to false in a single line
* Switched method of setting chatRevoked flag so that it is updated locally and in the database
* Removed some code that got re-added after rebase
* Tests for automatic slur muting pass but are incomplete (do not check that chatRevoked flag is true)
* Moved list of banned slurs to server side
* Added warning to bannedSlurs file
* Test chat privileges revoked when posting slur in public chat
* Fix issues left over after rebase (I hope)
* Added code to test for revoked chat privileges after posting a slur in a private group
* Moved banned slur message into locales message
* Added new code to check for banned slurs (parallels banned words code)
* Fixed AUTHOR_MOTAL_URL in sendTxn for slur blocking
* Added tests that email sent on attempted slur in chat post
* Created context for slur-related-tests, fixed sandboxing of email. Successfully tests that email.sendTxn is called, but the email content test fails
* commented out slack (for now) and cleaned up tests of sending email
* Successfully tests that slur-report-to-mods email is sent
* Slack message is sent, and testing works, but some user variables seem to only work when found in chat.js and passed to slack
* Made some fixes for lint, but not sure what to do about the camel case requirement fail, since that's how they're defined in other slack calls
* Slack tests pass, skipped camelcase check around those code blocks
* Fixed InternalServerError caused by slack messaging
* Updated chat privileges revoked error
* fix(locale): typo correction
2017-07-19 21:06:15 +00:00
} ;