discourse-ai/lib/modules/toxicity/jobs/regular/toxicity_classify_chat_message.rb
2023-02-24 07:53:43 -03:00

17 lines
445 B
Ruby

# frozen_string_literal: true
module ::Jobs
class ToxicityClassifyChatMessage < ::Jobs::Base
def execute(args)
return unless SiteSetting.ai_toxicity_enabled
return if (chat_message_id = args[:chat_message_id]).blank?
chat_message = ChatMessage.find_by(id: chat_message_id)
return if chat_message&.message.blank?
::DiscourseAI::Toxicity::ChatMessageClassifier.new.classify!(chat_message)
end
end
end