-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad word filter Feature (Ready to Use) :D #2940
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,10 @@ Package.describe({ | |
git: '' | ||
}); | ||
|
||
Npm.depends({ | ||
'bad-words': '1.3.1' | ||
}); | ||
|
||
Package.onUse(function(api) { | ||
api.versionsFrom('1.0'); | ||
|
||
|
@@ -97,6 +101,7 @@ Package.onUse(function(api) { | |
api.addFiles('server/methods/insertOrUpdateUser.coffee', 'server'); | ||
api.addFiles('server/methods/setEmail.js', 'server'); | ||
api.addFiles('server/methods/restartServer.coffee', 'server'); | ||
api.addFiles('server/methods/filterBadWords.js', ['server']); | ||
|
||
// SERVER STARTUP | ||
api.addFiles('server/startup/settingsOnLoadCdnPrefix.coffee', 'server'); | ||
|
@@ -147,6 +152,8 @@ Package.onUse(function(api) { | |
api.imply('tap:i18n'); | ||
}); | ||
|
||
|
||
|
||
Package.onTest(function(api) { | ||
api.use('coffeescript'); | ||
api.use('sanjo:[email protected]'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
var Filter = Npm.require('bad-words'); | ||
|
||
RocketChat.callbacks.add( 'beforeSaveMessage' , function(message){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: There should be no space before ','. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Missing space before opening brace. |
||
// console.log(message) | ||
|
||
if( RocketChat.settings.get('Message_AllowBadWordsFilter') ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Keyword "if" must be followed by whitespace. |
||
{ | ||
|
||
var badWordsList = RocketChat.settings.get('Message_BadWordsFilterList'); | ||
// console.log(badWordsList) | ||
//Add words to the blacklist | ||
if(!!badWordsList && badWordsList.length) | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Trailing spaces not allowed. |
||
// console.log(badWordsList) | ||
var filter = new Filter({ list: badWordsList.split(',') }); | ||
} | ||
else | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Expected { after 'else'. |
||
var filter = new Filter(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Expected '{' and instead saw 'var'. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Variable 'filter' is already declared in line 16. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: "filter" is already defined |
||
message.msg = filter.clean(message.msg); | ||
|
||
} | ||
return message; | ||
|
||
},1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: A space is required after ','. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Trailing spaces not allowed.