mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 09:08:10 +08:00
SECURITY: Generate more category CSS on client
This commit moves the generation of category background CSS from the server side to the client side. This simplifies the server side code because it does not need to check which categories are visible to the current user.
This commit is contained in:
@ -240,20 +240,13 @@ class Stylesheet::Manager::Builder
|
||||
def color_scheme_digest
|
||||
cs = @color_scheme || theme&.color_scheme
|
||||
|
||||
categories_updated =
|
||||
Stylesheet::Manager
|
||||
.cache
|
||||
.defer_get_set("categories_updated") do
|
||||
Category.where("uploaded_background_id IS NOT NULL").pluck(:updated_at).map(&:to_i).sum
|
||||
end
|
||||
|
||||
fonts = "#{SiteSetting.base_font}-#{SiteSetting.heading_font}"
|
||||
|
||||
digest_string = "#{current_hostname}-"
|
||||
if cs || categories_updated > 0
|
||||
if cs
|
||||
theme_color_defs = resolve_baked_field(:common, :color_definitions)
|
||||
digest_string +=
|
||||
"#{RailsMultisite::ConnectionManagement.current_db}-#{cs&.id}-#{cs&.version}-#{theme_color_defs}-#{Stylesheet::Manager.fs_asset_cachebuster}-#{categories_updated}-#{fonts}"
|
||||
"#{RailsMultisite::ConnectionManagement.current_db}-#{cs&.id}-#{cs&.version}-#{theme_color_defs}-#{Stylesheet::Manager.fs_asset_cachebuster}-#{fonts}"
|
||||
else
|
||||
digest_string += "defaults-#{Stylesheet::Manager.fs_asset_cachebuster}-#{fonts}"
|
||||
|
||||
|
Reference in New Issue
Block a user