2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-04-18 10:48:01 -05:00
|
|
|
DiscourseEvent.on(:site_setting_changed) do |name, old_value, new_value|
|
2020-04-09 07:42:24 -05:00
|
|
|
Category.clear_subcategory_ids if name === :max_category_nesting
|
|
|
|
|
2019-04-18 10:48:01 -05:00
|
|
|
# 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
|
2020-03-02 13:33:52 -06:00
|
|
|
|
|
|
|
User.where(approved: false)
|
|
|
|
.joins("LEFT JOIN reviewables r ON r.target_id = users.id")
|
|
|
|
.where(r: { id: nil }).update_all(approved: true)
|
2019-04-16 13:42:47 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
if name == :emoji_set
|
|
|
|
Emoji.clear_cache
|
|
|
|
|
2019-04-18 10:48:01 -05:00
|
|
|
before = "/images/emoji/#{old_value}/"
|
|
|
|
after = "/images/emoji/#{new_value}/"
|
2019-04-16 13:42:47 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2019-12-24 07:11:37 -06:00
|
|
|
Jobs.enqueue(:update_s3_inventory) if [:enable_s3_inventory, :s3_upload_bucket].include?(name)
|
2019-04-16 13:42:47 -05:00
|
|
|
|
|
|
|
SvgSprite.expire_cache if name.to_s.include?("_icon")
|
2019-05-01 08:44:45 -05:00
|
|
|
|
|
|
|
if SiteIconManager::WATCHED_SETTINGS.include?(name)
|
|
|
|
SiteIconManager.ensure_optimized!
|
|
|
|
end
|
2019-07-12 13:42:43 -05:00
|
|
|
|
|
|
|
if SiteSetting::WATCHED_SETTINGS.include?(name)
|
|
|
|
SiteSetting.reset_cached_settings!
|
|
|
|
end
|
2019-04-16 13:42:47 -05:00
|
|
|
end
|