mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-26 21:18:34 +08:00
We should allow authors to localize their own content. This is gated behind the `content_localization_allow_author_localization` setting, which is enabled by default. Meta: https://meta.discourse.org/t/feature-request-allow-users-to-localize-only-their-own-topics/389147
25 lines
814 B
Ruby
Vendored
25 lines
814 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class ProcessLocalizedCooked < ::Jobs::Base
|
|
def execute(args)
|
|
DistributedMutex.synchronize(
|
|
"process_localized_cook_#{args[:post_localization_id]}",
|
|
validity: 10.minutes,
|
|
) do
|
|
post_localization = PostLocalization.find_by(id: args[:post_localization_id])
|
|
return if post_localization.blank?
|
|
|
|
post = post_localization.post
|
|
return if post.blank? || post.topic.blank?
|
|
|
|
processor = LocalizedCookedPostProcessor.new(post_localization, post, {})
|
|
processor.post_process
|
|
cooked = processor.html.strip
|
|
|
|
post_localization.update_column(:cooked, cooked) if cooked.present?
|
|
MessageBus.publish("/topic/#{post.topic_id}", type: :localized, id: post.id)
|
|
end
|
|
end
|
|
end
|
|
end
|