Skip to content
Snippets Groups Projects
Unverified Commit ec2d63e9 authored by Aryan Koul's avatar Aryan Koul Committed by GitHub
Browse files

[NEW] Whitelisting bad words (#17120)

parent 97bdfb56
No related branches found
No related tags found
No related merge requests found
......@@ -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",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment