2020-01-16 07:08:32 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Spam
|
|
|
|
class MarkAsSpamService
|
|
|
|
include ::AkismetMethods
|
|
|
|
|
2020-02-27 07:09:12 -05:00
|
|
|
attr_accessor :target, :options
|
2020-01-16 07:08:32 -05:00
|
|
|
|
2020-02-27 07:09:12 -05:00
|
|
|
def initialize(target:)
|
|
|
|
@target = target
|
2020-01-16 07:08:32 -05:00
|
|
|
@options = {}
|
|
|
|
|
2020-02-27 07:09:12 -05:00
|
|
|
@options[:ip_address] = @target.ip_address
|
|
|
|
@options[:user_agent] = @target.user_agent
|
2020-01-16 07:08:32 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2020-02-27 07:09:12 -05:00
|
|
|
return unless target.submittable_as_spam?
|
2020-01-16 07:08:32 -05:00
|
|
|
return unless akismet.submit_spam
|
|
|
|
|
2020-02-27 07:09:12 -05:00
|
|
|
target.user_agent_detail.update_attribute(:submitted, true)
|
2020-01-16 07:08:32 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|