discourse-ai/lib/modules/toxicity/jobs/regular/toxicity_classify_post.rb

18 lines
417 B
Ruby
Raw Normal View History

2023-02-22 18:46:53 -05:00
# frozen_string_literal: true
module ::Jobs
class ToxicityClassifyPost < ::Jobs::Base
def execute(args)
return unless SiteSetting.ai_toxicity_enabled
post_id = args[:post_id]
return if post_id.blank?
post = Post.find_by(id: post_id, post_type: Post.types[:regular])
return if post&.raw.blank?
::DiscourseAI::Toxicity::PostClassifier.new(post).classify!
end
end
end