mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 10:54:22 +08:00
097851c135
If the “secure media” site setting is enabled then ALL files uploaded to Discourse (images, video, audio, pdf, txt, zip etc. etc.) will follow the secure media rules. The “prevent anons from downloading files” setting will no longer have any bearing on upload security. Basically, the feature will more appropriately be called “secure uploads” instead of “secure media”. This is being done because there are communities out there that would like all attachments and media to be secure based on category rules but still allow anonymous users to download attachments in public places, which is not possible in the current arrangement.
48 lines
1.4 KiB
Ruby
48 lines
1.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
DiscourseEvent.on(:site_setting_changed) do |name, old_value, new_value|
|
|
# Enabling `must_approve_users` on an existing site is odd, so we assume that the
|
|
# existing users are approved.
|
|
if name == :must_approve_users && new_value == true
|
|
|
|
User.where(approved: false)
|
|
.joins("LEFT JOIN reviewables r ON r.target_id = users.id")
|
|
.where(r: { id: nil }).update_all(approved: true)
|
|
end
|
|
|
|
if name == :emoji_set
|
|
Emoji.clear_cache
|
|
|
|
before = "/images/emoji/#{old_value}/"
|
|
after = "/images/emoji/#{new_value}/"
|
|
|
|
Scheduler::Defer.later("Fix Emoji Links") do
|
|
DB.exec("UPDATE posts SET cooked = REPLACE(cooked, :before, :after) WHERE cooked LIKE :like",
|
|
before: before,
|
|
after: after,
|
|
like: "%#{before}%"
|
|
)
|
|
end
|
|
end
|
|
|
|
Report.clear_cache(:storage_stats) if [:backup_location, :s3_backup_bucket].include?(name)
|
|
|
|
if name == :slug_generation_method
|
|
Scheduler::Defer.later("Null topic slug") do
|
|
Topic.update_all(slug: nil)
|
|
end
|
|
end
|
|
|
|
Jobs.enqueue(:update_s3_inventory) if [:enable_s3_inventory, :s3_upload_bucket].include?(name)
|
|
|
|
SvgSprite.expire_cache if name.to_s.include?("_icon")
|
|
|
|
if SiteIconManager::WATCHED_SETTINGS.include?(name)
|
|
SiteIconManager.ensure_optimized!
|
|
end
|
|
|
|
if SiteSetting::WATCHED_SETTINGS.include?(name)
|
|
SiteSetting.reset_cached_settings!
|
|
end
|
|
end
|