Commit 8b3da021 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'cablett-spam-tidy-ham-akismet-service' into 'master'

Modify HamService to use AkismetMethods

See merge request gitlab-org/gitlab!24633
parents e5b27582 43e25d6e
...@@ -9,7 +9,7 @@ module AkismetMethods ...@@ -9,7 +9,7 @@ module AkismetMethods
@akismet ||= Spam::AkismetService.new( @akismet ||= Spam::AkismetService.new(
spammable_owner.name, spammable_owner.name,
spammable_owner.email, spammable_owner.email,
spammable.spammable_text, spammable.try(:spammable_text) || spammable&.text,
options options
) )
end end
......
...@@ -2,10 +2,17 @@ ...@@ -2,10 +2,17 @@
module Spam module Spam
class HamService class HamService
attr_accessor :spam_log include AkismetMethods
attr_accessor :spam_log, :options
def initialize(spam_log) def initialize(spam_log)
@spam_log = spam_log @spam_log = spam_log
@user = spam_log.user
@options = {
ip_address: spam_log.source_ip,
user_agent: spam_log.user_agent
}
end end
def execute def execute
...@@ -16,17 +23,6 @@ module Spam ...@@ -16,17 +23,6 @@ module Spam
end end
end end
private alias_method :spammable, :spam_log
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
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment