discourse-akismet/jobs/regular/check_akismet_post.rb
Osama Sayegh 2d3d2bbfe2
DEV: Don't raise an exception inside a job (#48)
* DEV: Don't raise an exception inside a job

* Apply Regis suggestion
2019-11-15 19:12:08 +03:00

19 lines
533 B
Ruby

# frozen_string_literal: true
module Jobs
class CheckAkismetPost < ::Jobs::Base
# Check a single post for spam. We do this for TL0 to get a faster response
# without batching.
def execute(args)
return unless SiteSetting.akismet_enabled?
return unless post = Post.find_by(id: args[:post_id], user_deleted: false)
return if ReviewableQueuedPost.exists?(target: post)
client = Akismet::Client.build_client
DiscourseAkismet::PostsBouncer.new.perform_check(client, post)
end
end
end