Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/lib/server/methods/filterBadWords.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

Expand Down
4 changes: 4 additions & 0 deletions app/lib/server/startup/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2467,6 +2467,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",
Expand Down