mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-22 09:36:49 +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
15 lines
414 B
Ruby
Vendored
15 lines
414 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
class PostLocalizationDestroyer
|
|
def self.destroy(post_id:, locale:, acting_user:)
|
|
Guardian.new(acting_user).ensure_can_localize_post!(post_id)
|
|
|
|
localization = PostLocalization.find_by(post_id:, locale:)
|
|
raise Discourse::NotFound unless localization
|
|
|
|
localization.destroy!
|
|
|
|
post = localization.post
|
|
post.publish_change_to_clients! :revised if post
|
|
end
|
|
end
|