Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ham_service.rb « spam « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e8444ba8f93545d681089bb51265ecbb36d9e781 (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
29
30
31
32
# frozen_string_literal: true

module Spam
  class HamService
    attr_accessor :spam_log

    def initialize(spam_log)
      @spam_log = spam_log
    end

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

    private

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