joshfrench / rakismet

Easy Akismet and TypePad AntiSpam integration for Rails
MIT License
355 stars 46 forks source link

Rakisment response issue. #4

Closed bethink closed 14 years ago

bethink commented 14 years ago

Hi,

I am using Rakismet plugin in my Rails application to check a comment is spam or not. I am using typepad api for that.


configurations in my initializer and model:

Rakismet::KEY = '8ef8ccb04d9c1f0049041c86371982a6' Rakismet::URL = 'http://www.postonline.co.uk/' Rakismet::HOST = 'api.antispam.typepad.com'

has_rakismet :author => :user_name, :author_url => :author_url, :author_email => :email, :comment_type => :status, :content => :description, :permalink => :permalink, :user_ip => :ip_address, :referrer => :referrer


I felt that i am doing mistake some where, since i always got the spam response ( @comment.spam? => 'false' ) as false, even if i submit @comment as spam ( @comment.spam! ), So i tried to trace the rakismet plugin. I got some results while tracing.


  def validate_key
    validate_constants
    akismet = URI.parse(verify_url)
    _, valid = Net::HTTP.start(akismet.host) do |http|
      data = "key=#{Rakismet::KEY}&blog=#{Rakismet::URL}"
      http.post(akismet.path, data, Rakismet::HEADERS)
    end
    self.valid_key = (valid == 'valid')
  end

verify_url => "http://api.antispam.typepad.com/1.1/verify-key"

data => "key=8ef8ccb04d9c1f0049041c86371982a6&blog=http://www.postonline.co.uk/"

Rakismet::HEADERS => {"Content-Type"=>"application/x-www-form-urlencoded", "User-Agent"=>"Rails/2.2.2 | Rakismet/0.3.5"}

_, result = http.post(akismet.path, data, Rakismet::HEADERS) result => 'valid'


As per my configuration in initializer i can sure that my api key is valid, since validate_key method returns true. And i have got this key from typepad site.

If i write wrong key ( like Rakismet::KEY = 'bangalore is a great city' ) also i am getting the same positive response ( validate_key => true )

also,

@comment.akismet_response => always 'false' @comment.spam! => "Feedback received." @comment.spam!? => 'false'

I am using Rails 2.2.2 and Rakismet 0.3.5.

Where i am doing mistake?

Thanks in advance.

With Regards,

Manoj


joshfrench commented 14 years ago

Hi Manoj,

You're not doing anything wrong. TypePad just doesn't believe you're a spammer. This is a good thing: it means the service is smart enough to reject false positives.

If you set @comment.author_name = "viagra-test-123", TypePad will always return a true response. That's the only reliable way of triggering spam? => true.

Also, calling @comment.spam! does not change the value of @comment.spam?. spam! only tells TypePad that you think this comment is spam; the next time you call spam? Rakismet still makes a call to TypePad, who may disagree with you.

Let me know if you have any other questions. Josh

joshfrench commented 14 years ago

(Oh, and you may want to obtain a new API key now that you've posted yours publicly.)

bethink commented 14 years ago

Thanks Josh for your replay. It is working fine for me if i set the author_name as "viagra-test-123".

One more question,

If i give the wrong key also TypePad is giving response. ( Rakismet::KEY = 'manoj8ef8ccb04d9c1f0049041c86371982a6' ) Then what is the actual purpose of the key.

With Regards,

Manoj

joshfrench commented 14 years ago

I had not noticed that, but you are correct. Akismet properly returns "invalid" if you pass a bad key; TypePad doesn't. I don't know why that would be.

j

bethink commented 14 years ago

Could you give some other spammy words like 'viagra-test-123' which will make comment as spam in TypePad.

Manoj

joshfrench commented 14 years ago

"viagra-test-123" is a testing phrase built into Akismet and TypePad. I don't think there are any others, unfortunately.

bethink commented 14 years ago

Thanks josh.