Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-29 15:09:08 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-29 15:09:08 +0300
commit7cc6872401eb487ed20dbb9d455f8bb9c97d9e39 (patch)
tree63f6ed5d4e6c5cec31c43363626d9f5b178eddf8 /app/services/spam
parent46b10c0fc884400941c17e2777b242ac54d111e5 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/spam')
-rw-r--r--app/services/spam/ham_service.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/app/services/spam/ham_service.rb b/app/services/spam/ham_service.rb
new file mode 100644
index 00000000000..f367eb8c21e
--- /dev/null
+++ b/app/services/spam/ham_service.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+module Spam
+ class HamService
+ attr_accessor :spam_log
+
+ def initialize(spam_log)
+ @spam_log = spam_log
+ end
+
+ def mark_as_ham!
+ if akismet.submit_ham
+ spam_log.update_attribute(:submitted_as_ham, true)
+ else
+ false
+ end
+ end
+
+ private
+
+ def akismet
+ user = spam_log.user
+ @akismet ||= AkismetService.new(
+ user.name,
+ user.email,
+ spam_log.text,
+ ip_address: spam_log.source_ip,
+ user_agent: spam_log.user_agent
+ )
+ end
+ end
+end