0
0
Fork 0

Add authorized_fetch server setting in addition to env var (#25798)

This commit is contained in:
Claire 2023-09-01 15:41:10 +02:00 committed by GitHub
parent 6c4c72497a
commit 9e26cd5503
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 43 additions and 8 deletions

View file

@ -3,6 +3,8 @@
class Form::AdminSettings
include ActiveModel::Model
include AuthorizedFetchHelper
KEYS = %i(
site_contact_username
site_contact_email
@ -34,6 +36,7 @@ class Form::AdminSettings
backups_retention_period
status_page_url
captcha_enabled
authorized_fetch
).freeze
INTEGER_KEYS = %i(
@ -54,6 +57,7 @@ class Form::AdminSettings
noindex
require_invite_text
captcha_enabled
authorized_fetch
).freeze
UPLOAD_KEYS = %i(
@ -61,6 +65,10 @@ class Form::AdminSettings
mascot
).freeze
OVERRIDEN_SETTINGS = {
authorized_fetch: :authorized_fetch_mode?,
}.freeze
attr_accessor(*KEYS)
validates :registrations_mode, inclusion: { in: %w(open approved none) }, if: -> { defined?(@registrations_mode) }
@ -80,6 +88,8 @@ class Form::AdminSettings
stored_value = if UPLOAD_KEYS.include?(key)
SiteUpload.where(var: key).first_or_initialize(var: key)
elsif OVERRIDEN_SETTINGS.include?(key)
public_send(OVERRIDEN_SETTINGS[key])
else
Setting.public_send(key)
end