mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-27 13:45:29 +08:00
Some site settings support backfilling if the user specified it. This works fine for singular site settings sent to the SiteSettingsController#update endpoint, but with bulk save we need to support this for a list of settings as well. This change alters the params format for SiteSetting::Update. It also moves the backfill logic into the service.
33 lines
869 B
Ruby
Vendored
33 lines
869 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
class SiteSetting::Policy::SettingsAreNotDeprecated < Service::PolicyBase
|
|
delegate :options, :params, to: :context
|
|
|
|
def call
|
|
@hard_deprecations =
|
|
params.settings.filter_map do |setting|
|
|
SiteSettings::DeprecatedSettings::SETTINGS.find do |old_name, new_name, override, _|
|
|
if old_name.to_sym == setting.name
|
|
if override
|
|
options.overridden_setting_names[old_name.to_sym] = new_name
|
|
break
|
|
else
|
|
break old_name, new_name
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
@hard_deprecations.empty?
|
|
end
|
|
|
|
def reason
|
|
old_names, new_names = @hard_deprecations.transpose
|
|
|
|
I18n.t(
|
|
"errors.site_settings.site_settings_are_deprecated",
|
|
old_names: old_names.join(", "),
|
|
new_names: new_names.join(", "),
|
|
)
|
|
end
|
|
end
|