2025-05-29 17:28:06 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module DiscourseAi
|
|
|
|
module Translation
|
|
|
|
class EntryPoint
|
|
|
|
def inject_into(plugin)
|
2025-06-18 13:24:02 +08:00
|
|
|
plugin.on(:post_created) do |post|
|
2025-05-29 17:28:06 +08:00
|
|
|
if SiteSetting.discourse_ai_enabled && SiteSetting.ai_translation_enabled
|
|
|
|
Jobs.enqueue(:detect_translate_post, post_id: post.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
plugin.on(:topic_created) do |topic|
|
|
|
|
if SiteSetting.discourse_ai_enabled && SiteSetting.ai_translation_enabled
|
|
|
|
Jobs.enqueue(:detect_translate_topic, topic_id: topic.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
plugin.on(:post_edited) do |post, topic_changed|
|
|
|
|
if SiteSetting.discourse_ai_enabled && SiteSetting.ai_translation_enabled && topic_changed
|
|
|
|
Jobs.enqueue(:detect_translate_topic, topic_id: post.topic_id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|