mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-19 02:05:37 +08:00
There are three bugs fixed here: ## bug 1 `revisor.should_create_new_version?` does not trigger when an upload is added. This means localizations will not be updated. This is now fixed by not using `should_create_new_version` but `raw_changed` instead. m/t/389685/15 ## bug 2 When the topic's first post is updated, it does not update the topic_localization excerpt. This is now fixed. t/169370/3 ## bug 3 When the topic title is edited (entry_point.rb), the `detect_translate_topic` job is enqueued, however, localization does not happen because it already exists. The job now is consistent and relocalizes based on a daily quota. t/169370/3
37 lines
1.1 KiB
Ruby
Vendored
37 lines
1.1 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module DiscourseAi
|
|
module Translation
|
|
class EntryPoint
|
|
def inject_into(plugin)
|
|
plugin.on(:post_created) do |post|
|
|
if DiscourseAi::Translation.enabled?
|
|
Jobs.enqueue(:detect_translate_post, post_id: post.id)
|
|
end
|
|
end
|
|
|
|
plugin.on(:topic_created) do |topic|
|
|
if DiscourseAi::Translation.enabled?
|
|
Jobs.enqueue(:detect_translate_topic, topic_id: topic.id)
|
|
end
|
|
end
|
|
|
|
plugin.on(:post_edited) do |post, _, revisor|
|
|
if DiscourseAi::Translation.enabled?
|
|
grace = [SiteSetting.editing_grace_period.seconds, 5.minutes].max
|
|
|
|
title_changed = revisor.topic_title_changed?
|
|
raw_changed = revisor.raw_changed?
|
|
excerpt_changed = post.is_first_post? && raw_changed
|
|
|
|
if title_changed || excerpt_changed
|
|
Jobs.enqueue_in(grace, :detect_translate_topic, topic_id: post.topic_id)
|
|
end
|
|
|
|
Jobs.enqueue_in(grace, :detect_translate_post, post_id: post.id) if raw_changed
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|