mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 17:53:40 +08:00
8ebd5edd1e
This commit renames all secure_media related settings to secure_uploads_* along with the associated functionality. This is being done because "media" does not really cover it, we aren't just doing this for images and videos etc. but for all uploads in the site. Additionally, in future we want to secure more types of uploads, and enable a kind of "mixed mode" where some uploads are secure and some are not, so keeping media in the name is just confusing. This also keeps compatibility with the `secure-media-uploads` path, and changes new secure URLs to be `secure-uploads`. Deprecated settings: * secure_media -> secure_uploads * secure_media_allow_embed_images_in_emails -> secure_uploads_allow_embed_images_in_emails * secure_media_max_email_embed_image_size_kb -> secure_uploads_max_email_embed_image_size_kb
72 lines
2.4 KiB
Ruby
72 lines
2.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module SiteSettings; end
|
|
|
|
module SiteSettings::DeprecatedSettings
|
|
SETTINGS = [
|
|
# [<old setting>, <new_setting>, <override>, <version to drop>]
|
|
['search_tokenize_chinese_japanese_korean', 'search_tokenize_chinese', true, '2.9'],
|
|
['default_categories_regular', 'default_categories_normal', true, '3.0'],
|
|
['min_trust_to_send_messages', 'personal_message_enabled_groups', false, '3.0'],
|
|
['enable_personal_messages', 'personal_message_enabled_groups', false, '3.0'],
|
|
['secure_media', 'secure_uploads', true, '3.0'],
|
|
['secure_media_allow_embed_images_in_emails', 'secure_uploads_allow_embed_images_in_emails', true, '3.0'],
|
|
['secure_media_max_email_embed_image_size_kb', 'secure_uploads_max_email_embed_image_size_kb', true, '3.0'],
|
|
]
|
|
|
|
def setup_deprecated_methods
|
|
SETTINGS.each do |old_setting, new_setting, override, version|
|
|
unless override
|
|
SiteSetting.singleton_class.public_send(
|
|
:alias_method, :"_#{old_setting}", :"#{old_setting}"
|
|
)
|
|
end
|
|
|
|
define_singleton_method old_setting do |warn: true|
|
|
if warn
|
|
Discourse.deprecate(
|
|
"`SiteSetting.#{old_setting}` has been deprecated. Please use `SiteSetting.#{new_setting}` instead.",
|
|
drop_from: version
|
|
)
|
|
end
|
|
|
|
self.public_send(override ? new_setting : "_#{old_setting}")
|
|
end
|
|
|
|
unless override
|
|
SiteSetting.singleton_class.public_send(
|
|
:alias_method, :"_#{old_setting}?", :"#{old_setting}?"
|
|
)
|
|
end
|
|
|
|
define_singleton_method "#{old_setting}?" do |warn: true|
|
|
if warn
|
|
Discourse.deprecate(
|
|
"`SiteSetting.#{old_setting}?` has been deprecated. Please use `SiteSetting.#{new_setting}?` instead.",
|
|
drop_from: version
|
|
)
|
|
end
|
|
|
|
self.public_send("#{override ? new_setting : "_" + old_setting}?")
|
|
end
|
|
|
|
unless override
|
|
SiteSetting.singleton_class.public_send(
|
|
:alias_method, :"_#{old_setting}=", :"#{old_setting}="
|
|
)
|
|
end
|
|
|
|
define_singleton_method "#{old_setting}=" do |val, warn: true|
|
|
if warn
|
|
Discourse.deprecate(
|
|
"`SiteSetting.#{old_setting}=` has been deprecated. Please use `SiteSetting.#{new_setting}=` instead.",
|
|
drop_from: version
|
|
)
|
|
end
|
|
|
|
self.public_send("#{override ? new_setting : "_" + old_setting}=", val)
|
|
end
|
|
end
|
|
end
|
|
end
|