Akismet: Use for existing posts?

Hi, a quick question.

Do you think Discourse Akismet can somehow be used to detect spam in the existing posts?

I’m importing a forum with a lot of spam and I can’t clean it up all before importing to Discourse.

3 Likes

I think that I might do that it in import script, though I’m not quite sure just how.

2 Likes

It’s possible, but I think you’ll have to make changes to the import script.

You’ll need to be able to instantiate this class in the script:

https://github.com/discourse/discourse-akismet/blob/master/lib/akismet.rb

You may need to copy the code and adapt it to work without Discourse specific code like Discourse.base_url, SiteSetting.akismet_api_key, etc.

The client #comment_check method expects a body, so you’ll have to build something like this:

https://github.com/discourse/discourse-akismet/blob/master/lib/discourse_akismet/posts_bouncer.rb#L82

More info about this here.

Then you could do something like this:

# Check if a post is spam.
client = Akismet.build_client
body = <your code>

is_spam = client.comment_check(body)
5 Likes