Class: Antispam::Spamcheckers::Defendium

Inherits:
Object
  • Object
show all
Defined in:
lib/antispam/spamcheckers/defendium.rb

Class Method Summary collapse

Class Method Details

.check(content, key, verbose) ⇒ Object

Returns a boolean, 1 for spam, 0 for not spam.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/antispam/spamcheckers/defendium.rb', line 6

def self.check(content, key, verbose)
  # nethttp2.rb
  require 'uri'
  require 'net/http'

  uri = URI('https://api.defendium.com/check')
  params = { secret_key: key, content: content }
  uri.query = URI.encode_www_form(params)

  res = Net::HTTP.get_response(uri)
  if res.is_a?(Net::HTTPSuccess)
    result = res.body.to_json
    if result["warnings"]
      Rails.logger.info result["warnings"]
    end
    if result["result"]
      return 1
    else
      return 0
    end
  end
end