Commit 43e25d6e authored by charlieablett's avatar charlieablett

Modify HamService to use AkismetMethods

parent 8b39d9ed
......@@ -9,7 +9,7 @@ module AkismetMethods
@akismet ||= Spam::AkismetService.new(
spammable_owner.name,
spammable_owner.email,
spammable.spammable_text,
spammable.try(:spammable_text) || spammable&.text,
options
)
end
......
......@@ -2,10 +2,17 @@
module Spam
class HamService
attr_accessor :spam_log
include AkismetMethods
attr_accessor :spam_log, :options
def initialize(spam_log)
@spam_log = spam_log
@user = spam_log.user
@options = {
ip_address: spam_log.source_ip,
user_agent: spam_log.user_agent
}
end
def mark_as_ham!
......@@ -16,17 +23,6 @@ module Spam
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
alias_method :spammable, :spam_log
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