Sha256: 0dd5fe302b5e4b7ae86b6334b3e68d6f5202302b939b0bb79cb9bbfedc69752d

Contents?: true

Size: 785 Bytes

Versions: 11

Compression:

Stored size: 785 Bytes

Contents

#require 'resolv'
module Antispam
  module Spamcheckers
    class Defendium
      # Returns a boolean, 1 for spam, 0 for not spam.
      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
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
antispam-0.3.3 lib/antispam/spamcheckers/defendium.rb
antispam-0.3.2 lib/antispam/spamcheckers/defendium.rb
antispam-0.3.1 lib/antispam/spamcheckers/defendium.rb
antispam-0.3.0 lib/antispam/spamcheckers/defendium.rb
antispam-0.2.11 lib/antispam/spamcheckers/defendium.rb
antispam-0.2.10 lib/antispam/spamcheckers/defendium.rb
antispam-0.2.8 lib/antispam/spamcheckers/defendium.rb
antispam-0.2.6 lib/antispam/spamcheckers/defendium.rb
antispam-0.2.5 lib/antispam/spamcheckers/defendium.rb
antispam-0.2.4 lib/antispam/spamcheckers/defendium.rb
antispam-0.2.3 lib/antispam/spamcheckers/defendium.rb