mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
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:
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user