summaryrefslogtreecommitdiff
path: root/app/services/ham_service.rb
blob: 794eb34d9ca32c3a859f9bbd6011b9a5f8ff60a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

class HamService
  attr_accessor :spam_log

  def initialize(spam_log)
    @spam_log = spam_log
  end

  def mark_as_ham!
    if akismet.submit_ham
      spam_log.update_attribute(:submitted_as_ham, true)
    else
      false
    end
  end

  private

  def akismet
    @akismet ||= AkismetService.new(
      spam_log.user,
      spam_log.text,
      ip_address: spam_log.source_ip,
      user_agent: spam_log.user_agent
    )
  end
end