diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-07-30 07:18:32 +0300 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-08-15 21:18:15 +0300 |
commit | 64ab2b3d9f10366249c03a6bcf5e8b1d20010d8f (patch) | |
tree | 80f4e4b496c55c8aacfc37ee361330b015d9fad4 /lib | |
parent | 722fc84e3d4785fb3a9db5f1c7d2aabad22e8e01 (diff) |
Refactored spam related code even further
- Removed unnecessary column from `SpamLog`
- Moved creation of SpamLogs out of its own service and into SpamCheckService
- Simplified code in SpamCheckService.
- Moved move spam related code into Spammable concern
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/issues.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/akismet_helper.rb | 8 |
2 files changed, 3 insertions, 7 deletions
diff --git a/lib/api/issues.rb b/lib/api/issues.rb index 7bbfc137c2c..c4d3134da6c 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -160,7 +160,7 @@ module API issue = ::Issues::CreateService.new(project, current_user, attrs.merge(request: request, api: true)).execute - if issue.spam_detected? + if issue.spam? render_api_error!({ error: 'Spam detected' }, 400) end diff --git a/lib/gitlab/akismet_helper.rb b/lib/gitlab/akismet_helper.rb index 19e73820321..b74d8176cc7 100644 --- a/lib/gitlab/akismet_helper.rb +++ b/lib/gitlab/akismet_helper.rb @@ -17,10 +17,6 @@ module Gitlab env['HTTP_USER_AGENT'] end - def check_for_spam?(project) - akismet_enabled? && project.public? - end - def is_spam?(environment, user, text) client = akismet_client ip_address = client_ip(environment) @@ -44,7 +40,7 @@ module Gitlab end end - def ham!(details, text, user) + def ham!(ip_address, user_agent, text, user) client = akismet_client params = { @@ -55,7 +51,7 @@ module Gitlab } begin - client.submit_ham(details.ip_address, details.user_agent, params) + client.submit_ham(ip_address, user_agent, params) rescue => e Rails.logger.error("Unable to connect to Akismet: #{e}, skipping!") end |