[NEW] Whitelisting bad words (#17120)

Co-authored-by: pierre-lehnen-rc <55164754+pierre-lehnen-rc@users.noreply.github.com>
pull/19379/head
Aryan Koul 5 years ago committed by GitHub
parent 97bdfb56ae
commit ec2d63e913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      app/lib/server/methods/filterBadWords.js
  2. 4
      app/lib/server/startup/settings.js
  3. 2
      packages/rocketchat-i18n/i18n/en.i18n.json

@ -6,6 +6,7 @@ import { callbacks } from '../../../callbacks';
callbacks.add('beforeSaveMessage', function(message) {
if (settings.get('Message_AllowBadWordsFilter')) {
const badWordsList = settings.get('Message_BadWordsFilterList');
let whiteList = settings.get('Message_BadWordsWhitelist');
let options;
// Add words to the blacklist
@ -15,6 +16,12 @@ callbacks.add('beforeSaveMessage', function(message) {
};
}
const filter = new Filter(options);
if (whiteList?.length) {
whiteList = whiteList.split(',').map((word) => word.trim());
filter.removeWords(...whiteList);
}
message.msg = filter.clean(message.msg);
}

@ -1046,6 +1046,10 @@ settings.addGroup('Message', function() {
type: 'string',
public: true,
});
this.add('Message_BadWordsWhitelist', '', {
type: 'string',
public: true,
});
this.add('Message_KeepHistory', false, {
type: 'boolean',
public: true,

@ -2476,6 +2476,8 @@
"Message_AudioRecorderEnabled_Description": "Requires 'audio/mp3' files to be an accepted media type within 'File Upload' settings.",
"Message_BadWordsFilterList": "Add Bad Words to the Blacklist",
"Message_BadWordsFilterListDescription": "Add List of Comma-separated list of bad words to filter",
"Message_BadWordsWhitelist": "Remove words from the Blacklist",
"Message_BadWordsWhitelistDescription": "Add a comma-separated list of words to be removed from filter",
"Message_Characther_Limit": "Message Characther Limit",
"MessageBox_view_mode": "MessageBox View Mode",
"message_counter": "__counter__ message",

Loading…
Cancel
Save