joshfrench / rakismet

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

Doubts with the response #20

Closed localguiding closed 12 years ago

localguiding commented 12 years ago

Hi, I have forced spam? = true by using :author => "viagra-test-123". That's ok, I'm getting true Is there a way to set/force other comments as true ? I have tried in the console:

@comment = Comment.find(1) As you know I'm storing user_ip, user_agent and referrer in my model :) @comment.spam? # false @comment.spam! # true @comment.akismet_response # "false" Why do I get "false" here ???!!! @comment.spam? # true Ok, I'm happy with this true, but: @comment = Comment.find(1) @comment.spam? # false Ouch! WHY? I had set it to true before using spam!...

Thanks in advance.

ps: using raskimet 0.4.2, rails 2.3.5, ruby 1.8.7

joshfrench commented 12 years ago

When you call spam?, Akismet responds with one of true, false, or an error message. You can check the literal response with akismet_response. Calling spam! modifies the local value of spam? but it doesn't change what Akismet originally said -- that's why you still see false. (akismet_response is really meant as a way to investigate error messages, it's not the primary way to see if a comment is spam.)

When you find the comment again and call spam?, you're making another call to Akismet. Akismet still thinks your comment is fine. (Even though you called spam!, which does send that info back to Akismet, a single correction probably isn't enough to change Akismet's opinion.) If you want the value of spam? to remain consistent, you'll probably have to add a field to your model to store it. You could store the original value of spam? in there, and if you decide to change it with spam! or ham!, just update that field as well. That way you won't be asking Akismet every time, and if you disagree with Akismet you can preserve your own value.

Does that make sense?

localguiding commented 12 years ago

When you call spam?, Akismet responds with one of true, false, or an error message. You can check the literal >response with akismet_response. Calling spam! modifies the local value of spam? but it doesn't change what >Akismet originally said -- that's why you still see false. (akismet_response is really meant as a way to investigate >error messages, it's not the primary way to see if a comment is spam.)

When you find the comment again and call spam?, you're making another call to Akismet. Akismet still thinks your >comment is fine. (Even though you called spam!, which does send that info back to Akismet, a single correction >probably isn't enough to change Akismet's opinion.)

OK, thanks for your detailed answer ! Now I understand the issue.

If you want the value of spam? to remain consistent, you'll probably have to add a field to your model to store it. You could store the original value of spam? in there,

When should I store it, do you mean the FIRST TIME the comment is analyzed by akismet ?

and if you decide to change it with spam! or ham!, just update that field as well. That way you won't >be asking Akismet every time, and if you disagree with Akismet you can preserve your own value.

Ok, suppose I have an admin page with a list of 3 comment records and akismet parsed them as false Then I realized that 2 of them are actually spam. Using akismet (spam!) I set both as spam and update a new model field (lets say isSpam) to true. Then the spammer that created the previous 2 comments submit another comment. Akismet still think it is not an spam, even using the same user_ip, user_agen, referrer or whatever info equal to the previous 2 comments. How should I use isSpam or akismet to mark this new comment as spam ? I simple didn't understand the workflow you recommend my, sorry. Could you explain it again ?

Thanks !

joshfrench commented 12 years ago

I would always ask Akismet for spam? first, to get an initial value. I'd also set your custom isSpam field to the value spam? at the same time, so both fields are equal.

If you need to mark a comment as spam, just update isSpam to true.

Then, when you're outputting comments, always call isSpam instead of spam?, since spam? will fetch a response from Akismet but you want the locally stored value.

Does that make sense?

localguiding commented 12 years ago

Yes, thanks !