debian-mirror-gitlab/app/services/spam/akismet_mark_as_spam_service.rb

25 lines
511 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
module Spam
2021-10-27 15:23:28 +05:30
class AkismetMarkAsSpamService
2020-03-13 15:44:24 +05:30
include ::AkismetMethods
2020-04-08 14:13:33 +05:30
attr_accessor :target, :options
2020-03-13 15:44:24 +05:30
2020-04-08 14:13:33 +05:30
def initialize(target:)
@target = target
2020-03-13 15:44:24 +05:30
@options = {}
2021-10-27 15:23:28 +05:30
end
2020-03-13 15:44:24 +05:30
2021-10-27 15:23:28 +05:30
def execute
2020-04-08 14:13:33 +05:30
@options[:ip_address] = @target.ip_address
@options[:user_agent] = @target.user_agent
2020-03-13 15:44:24 +05:30
2020-04-08 14:13:33 +05:30
return unless target.submittable_as_spam?
2020-03-13 15:44:24 +05:30
return unless akismet.submit_spam
2020-04-08 14:13:33 +05:30
target.user_agent_detail.update_attribute(:submitted, true)
2020-03-13 15:44:24 +05:30
end
end
end