2020-01-29 07:09:08 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Spam
|
|
|
|
class HamService
|
2020-02-10 13:09:00 -05:00
|
|
|
include AkismetMethods
|
|
|
|
|
2020-02-14 19:08:48 -05:00
|
|
|
attr_accessor :spam_log, :options
|
2020-01-29 07:09:08 -05:00
|
|
|
|
2020-02-14 19:08:48 -05:00
|
|
|
def initialize(spam_log)
|
|
|
|
@spam_log = spam_log
|
|
|
|
@user = spam_log.user
|
2020-02-10 13:09:00 -05:00
|
|
|
@options = {
|
2020-02-14 19:08:48 -05:00
|
|
|
ip_address: spam_log.source_ip,
|
|
|
|
user_agent: spam_log.user_agent
|
2020-02-10 13:09:00 -05:00
|
|
|
}
|
2020-01-29 07:09:08 -05:00
|
|
|
end
|
|
|
|
|
2020-02-10 10:08:54 -05:00
|
|
|
def execute
|
2020-01-29 07:09:08 -05:00
|
|
|
if akismet.submit_ham
|
2020-02-14 19:08:48 -05:00
|
|
|
spam_log.update_attribute(:submitted_as_ham, true)
|
2020-01-29 07:09:08 -05:00
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
2020-02-14 19:08:48 -05:00
|
|
|
|
|
|
|
alias_method :spammable, :spam_log
|
2020-01-29 07:09:08 -05:00
|
|
|
end
|
|
|
|
end
|