2023-02-22 18:46:53 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module ::Jobs
|
2023-02-24 05:53:43 -05:00
|
|
|
class ToxicityClassifyChatMessage < ::Jobs::Base
|
2023-02-22 18:46:53 -05:00
|
|
|
def execute(args)
|
|
|
|
return unless SiteSetting.ai_toxicity_enabled
|
|
|
|
|
2023-02-24 05:53:43 -05:00
|
|
|
return if (chat_message_id = args[:chat_message_id]).blank?
|
2023-02-22 18:46:53 -05:00
|
|
|
|
|
|
|
chat_message = ChatMessage.find_by(id: chat_message_id)
|
|
|
|
return if chat_message&.message.blank?
|
|
|
|
|
2023-02-24 05:53:43 -05:00
|
|
|
::DiscourseAI::Toxicity::ChatMessageClassifier.new.classify!(chat_message)
|
2023-02-22 18:46:53 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|