diff options
Diffstat (limited to 'app/services/spam')
-rw-r--r-- | app/services/spam/akismet_service.rb | 6 | ||||
-rw-r--r-- | app/services/spam/spam_action_service.rb | 22 | ||||
-rw-r--r-- | app/services/spam/spam_verdict_service.rb | 21 |
3 files changed, 29 insertions, 20 deletions
diff --git a/app/services/spam/akismet_service.rb b/app/services/spam/akismet_service.rb index d31b904f549..fd2b3c9a441 100644 --- a/app/services/spam/akismet_service.rb +++ b/app/services/spam/akismet_service.rb @@ -50,8 +50,10 @@ module Spam attr_accessor :owner_name, :owner_email def akismet_client - @akismet_client ||= ::Akismet::Client.new(Gitlab::CurrentSettings.akismet_api_key, - Gitlab.config.gitlab.url) + @akismet_client ||= ::Akismet::Client.new( + Gitlab::CurrentSettings.akismet_api_key, + Gitlab.config.gitlab.url + ) end def akismet_enabled? diff --git a/app/services/spam/spam_action_service.rb b/app/services/spam/spam_action_service.rb index 5c510990b2d..6ec8d09c37c 100644 --- a/app/services/spam/spam_action_service.rb +++ b/app/services/spam/spam_action_service.rb @@ -76,10 +76,9 @@ module Spam spam_verdict_service.execute.tap do |result| case result when BLOCK_USER - # TODO: improve BLOCK_USER handling, non-existent until now - # https://gitlab.com/gitlab-org/gitlab/-/issues/329666 target.spam! create_spam_log + ban_user! when DISALLOW target.spam! create_spam_log @@ -119,6 +118,12 @@ module Spam target.spam_log = spam_log end + def ban_user! + UserCustomAttribute.set_banned_by_spam_log(target.spam_log) + + user.ban! + end + def spam_verdict_service context = { action: action, @@ -131,12 +136,13 @@ module Spam referer: spam_params&.referer } - SpamVerdictService.new(target: target, - user: user, - options: options, - context: context, - extra_features: extra_features - ) + SpamVerdictService.new( + target: target, + user: user, + options: options, + context: context, + extra_features: extra_features + ) end def noteable_type diff --git a/app/services/spam/spam_verdict_service.rb b/app/services/spam/spam_verdict_service.rb index 639d99ad906..9efe51b43b8 100644 --- a/app/services/spam/spam_verdict_service.rb +++ b/app/services/spam/spam_verdict_service.rb @@ -36,16 +36,17 @@ module Spam # The target can override the verdict via the `allow_possible_spam` application setting final_verdict = OVERRIDE_VIA_ALLOW_POSSIBLE_SPAM if override_via_allow_possible_spam?(verdict: final_verdict) - logger.info(class: self.class.name, - akismet_verdict: akismet_verdict, - spam_check_verdict: spamcheck_verdict, - spam_check_rtt: external_spam_check_round_trip_time.real, - final_verdict: final_verdict, - username: user.username, - user_id: user.id, - target_type: target.class.to_s, - project_id: target.project_id - ) + logger.info( + class: self.class.name, + akismet_verdict: akismet_verdict, + spam_check_verdict: spamcheck_verdict, + spam_check_rtt: external_spam_check_round_trip_time.real, + final_verdict: final_verdict, + username: user.username, + user_id: user.id, + target_type: target.class.to_s, + project_id: target.project_id + ) final_verdict end |