discourse-ai/lib/modules/toxicity/entry_point.rb

30 lines
954 B
Ruby

# frozen_string_literal: true
module DiscourseAI
module Toxicity
class EntryPoint
def load_files
require_relative "scan_queue"
require_relative "classifier"
require_relative "post_classifier"
require_relative "chat_message_classifier"
require_relative "jobs/regular/toxicity_classify_post"
require_relative "jobs/regular/toxicity_classify_chat_message"
end
def inject_into(plugin)
post_analysis_cb = Proc.new { |post| DiscourseAI::Toxicity::ScanQueue.enqueue_post(post) }
plugin.on(:post_created, &post_analysis_cb)
plugin.on(:post_edited, &post_analysis_cb)
chat_message_analysis_cb =
Proc.new { |message| DiscourseAI::Toxicity::ScanQueue.enqueue_chat_message(message) }
plugin.on(:chat_message_created, &chat_message_analysis_cb)
plugin.on(:chat_message_edited, &chat_message_analysis_cb)
end
end
end
end