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