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

25 lines
504 B
Ruby
Raw Normal View History

2020-03-09 13:42:32 +05:30
# frozen_string_literal: true
module Spam
class MarkAsSpamService
include ::AkismetMethods
2020-04-08 14:13:33 +05:30
attr_accessor :target, :options
2020-03-09 13:42:32 +05:30
2020-04-08 14:13:33 +05:30
def initialize(target:)
@target = target
2020-03-09 13:42:32 +05:30
@options = {}
2020-04-08 14:13:33 +05:30
@options[:ip_address] = @target.ip_address
@options[:user_agent] = @target.user_agent
2020-03-09 13:42:32 +05:30
end
def execute
2020-04-08 14:13:33 +05:30
return unless target.submittable_as_spam?
2020-03-09 13:42:32 +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-09 13:42:32 +05:30
end
end
end