Added block when user types a swear word listed in banned words (#8197)

* Added block when user types a swear word listed in banned words

* Moved banned words check to server

* Removed unused code

* Moved banned words to separate file and fixed grammar.

* Updated chat test

* Changed error to BadRequest

* Fixed regex matching

* Updated test banned word

* Moved banned words and cached regex

* Updated banned word message

* Add ban filter only for tavern

* Added tavern id constant

* Added more tests for banned words

* Added warning to banned words

* Added alert

* Added new regex to capture markdown

* Fixed lint, spelling and importing
This commit is contained in:
Keith Holliday
2017-04-24 07:55:42 -06:00
committed by GitHub
parent 7d3213fd66
commit d438990d18
7 changed files with 159 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
'use strict';
habitrpg.controller('ChatCtrl', ['$scope', 'Groups', 'Chat', 'User', '$http', 'ApiUrl', 'Notification', 'Members', '$rootScope', 'Analytics',
function($scope, Groups, Chat, User, $http, ApiUrl, Notification, Members, $rootScope, Analytics){
function($scope, Groups, Chat, User, $http, ApiUrl, Notification, Members, $rootScope, Analytics) {
$scope.message = {content:''};
$scope._sending = false;
@@ -23,7 +23,7 @@ habitrpg.controller('ChatCtrl', ['$scope', 'Groups', 'Chat', 'User', '$http', 'A
return message.highlight;
}
$scope.postChat = function(group, message){
$scope.postChat = function(group, message) {
if (_.isEmpty(message) || $scope._sending) return;
$scope._sending = true;
@@ -55,8 +55,12 @@ habitrpg.controller('ChatCtrl', ['$scope', 'Groups', 'Chat', 'User', '$http', 'A
} else {
Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'group chat','groupType':group.type,'privacy':group.privacy});
}
}, function(err){
})
.catch(function (err) {
$scope._sending = false;
if (err.data.message === env.t('bannedWordUsed')) {
alert(err.data.message);
}
});
}