mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-26 14:00:42 +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.
41 lines
1.2 KiB
Ruby
Vendored
41 lines
1.2 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
class Admin::Config::BrandingController < Admin::AdminController
|
|
def index
|
|
end
|
|
|
|
def logo
|
|
settings =
|
|
%i[
|
|
logo
|
|
logo_dark
|
|
large_icon
|
|
favicon
|
|
logo_small
|
|
logo_small_dark
|
|
mobile_logo
|
|
mobile_logo_dark
|
|
manifest_icon
|
|
manifest_screenshots
|
|
apple_touch_icon
|
|
digest_logo
|
|
opengraph_image
|
|
x_summary_large_image
|
|
].map { |setting| { setting_name: setting, value: params[setting] } }
|
|
|
|
SiteSetting::Update.call(guardian:, params: { settings: }) do
|
|
on_success { render json: success_json }
|
|
on_failed_policy(:settings_are_visible) do |policy|
|
|
raise Discourse::InvalidParameters, policy.reason
|
|
end
|
|
on_failed_policy(:settings_are_unshadowed_globally) do |policy|
|
|
raise Discourse::InvalidParameters, policy.reason
|
|
end
|
|
on_failed_policy(:settings_are_configurable) do |policy|
|
|
raise Discourse::InvalidParameters, policy.reason
|
|
end
|
|
on_failed_policy(:values_are_valid) do |policy|
|
|
raise Discourse::InvalidParameters, policy.reason
|
|
end
|
|
end
|
|
end
|
|
end
|