Merge tag 'v4.4.0-rc.1' into chinwag-next
This commit is contained in:
commit
fbbcaf4efd
2660 changed files with 83548 additions and 52192 deletions
|
|
@ -29,6 +29,7 @@ class Form::AdminSettings
|
|||
trendable_by_default
|
||||
show_domain_blocks
|
||||
show_domain_blocks_rationale
|
||||
allow_referrer_origin
|
||||
noindex
|
||||
require_invite_text
|
||||
media_cache_retention_period
|
||||
|
|
@ -39,6 +40,7 @@ class Form::AdminSettings
|
|||
authorized_fetch
|
||||
app_icon
|
||||
favicon
|
||||
min_age
|
||||
reject_pattern
|
||||
).freeze
|
||||
|
||||
|
|
@ -46,9 +48,11 @@ class Form::AdminSettings
|
|||
media_cache_retention_period
|
||||
content_cache_retention_period
|
||||
backups_retention_period
|
||||
min_age
|
||||
).freeze
|
||||
|
||||
BOOLEAN_KEYS = %i(
|
||||
allow_referrer_origin
|
||||
timeline_preview
|
||||
activity_api_enabled
|
||||
peers_api_enabled
|
||||
|
|
@ -70,6 +74,10 @@ class Form::AdminSettings
|
|||
favicon
|
||||
).freeze
|
||||
|
||||
DIGEST_KEYS = %i(
|
||||
custom_css
|
||||
).freeze
|
||||
|
||||
OVERRIDEN_SETTINGS = {
|
||||
authorized_fetch: :authorized_fetch_mode?,
|
||||
}.freeze
|
||||
|
|
@ -85,6 +93,7 @@ class Form::AdminSettings
|
|||
validates :show_domain_blocks, inclusion: { in: %w(disabled users all) }, if: -> { defined?(@show_domain_blocks) }
|
||||
validates :show_domain_blocks_rationale, inclusion: { in: %w(disabled users all) }, if: -> { defined?(@show_domain_blocks_rationale) }
|
||||
validates :media_cache_retention_period, :content_cache_retention_period, :backups_retention_period, numericality: { only_integer: true }, allow_blank: true, if: -> { defined?(@media_cache_retention_period) || defined?(@content_cache_retention_period) || defined?(@backups_retention_period) }
|
||||
validates :min_age, numericality: { only_integer: true }, allow_blank: true, if: -> { defined?(@min_age) }
|
||||
validates :site_short_description, length: { maximum: DESCRIPTION_LIMIT }, if: -> { defined?(@site_short_description) }
|
||||
validates :reject_pattern, regexp_syntax: true, if: -> { defined?(@reject_pattern) }
|
||||
validates :status_page_url, url: true, allow_blank: true
|
||||
|
|
@ -124,6 +133,8 @@ class Form::AdminSettings
|
|||
KEYS.each do |key|
|
||||
next unless instance_variable_defined?(:"@#{key}")
|
||||
|
||||
cache_digest_value(key) if DIGEST_KEYS.include?(key)
|
||||
|
||||
if UPLOAD_KEYS.include?(key)
|
||||
public_send(key).save
|
||||
else
|
||||
|
|
@ -135,6 +146,18 @@ class Form::AdminSettings
|
|||
|
||||
private
|
||||
|
||||
def cache_digest_value(key)
|
||||
Rails.cache.delete(:"setting_digest_#{key}")
|
||||
|
||||
key_value = instance_variable_get(:"@#{key}")
|
||||
if key_value.present?
|
||||
Rails.cache.write(
|
||||
:"setting_digest_#{key}",
|
||||
Digest::SHA256.hexdigest(key_value)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def typecast_value(key, value)
|
||||
if BOOLEAN_KEYS.include?(key)
|
||||
value == '1'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue