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?
|
|
|
|
|
2023-02-24 07:11:58 -05:00
|
|
|
post = Post.find_by(id: post_id, post_type: Post.types[:regular])
|
2023-02-22 18:46:53 -05:00
|
|
|
return if post&.raw.blank?
|
|
|
|
|
2023-02-28 09:17:03 -05:00
|
|
|
DiscourseAI::PostClassificator.new(
|
2023-02-24 11:25:02 -05:00
|
|
|
DiscourseAI::Toxicity::ToxicityClassification.new,
|
|
|
|
).classify!(post)
|
2023-02-22 18:46:53 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|