diff options
author | Robert Speicher <robert@gitlab.com> | 2016-08-15 22:59:47 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-08-15 22:59:47 +0000 |
commit | 7fef2f7b75e284b702f327cc073476724b51d5ac (patch) | |
tree | 05929a1c38682ee0bb17856492ff424915f85029 /lib | |
parent | 12918b0b9e99449181ce6f24c9bdb5d58ae6b89a (diff) | |
parent | 5994c11910822463faeabb7b5f11d6529036db9d (diff) | |
download | gitlab-ce-7fef2f7b75e284b702f327cc073476724b51d5ac.tar.gz |
Merge branch 'akismet-submittable' into 'master'
Submit to Akismet Part 1 (Issues)
Related to #5932 #5573 gitlab-com/infrastructure#14
See merge request !5538
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/issues.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/akismet_helper.rb | 47 |
2 files changed, 0 insertions, 49 deletions
diff --git a/lib/api/issues.rb b/lib/api/issues.rb index c4d3134da6c..077258faee1 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -3,8 +3,6 @@ module API class Issues < Grape::API before { authenticate! } - helpers ::Gitlab::AkismetHelper - helpers do def filter_issues_state(issues, state) case state diff --git a/lib/gitlab/akismet_helper.rb b/lib/gitlab/akismet_helper.rb deleted file mode 100644 index 207736b59db..00000000000 --- a/lib/gitlab/akismet_helper.rb +++ /dev/null @@ -1,47 +0,0 @@ -module Gitlab - module AkismetHelper - def akismet_enabled? - current_application_settings.akismet_enabled - end - - def akismet_client - @akismet_client ||= ::Akismet::Client.new(current_application_settings.akismet_api_key, - Gitlab.config.gitlab.url) - end - - def client_ip(env) - env['action_dispatch.remote_ip'].to_s - end - - def user_agent(env) - 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) - user_agent = user_agent(environment) - - params = { - type: 'comment', - text: text, - created_at: DateTime.now, - author: user.name, - author_email: user.email, - referrer: environment['HTTP_REFERER'], - } - - begin - is_spam, is_blatant = client.check(ip_address, user_agent, params) - is_spam || is_blatant - rescue => e - Rails.logger.error("Unable to connect to Akismet: #{e}, skipping check") - false - end - end - end -end |