2019-05-01 21:44:45 +08:00
|
|
|
require_dependency "site_icon_manager"
|
|
|
|
|
2019-04-18 23:48:01 +08:00
|
|
|
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
|
2019-04-17 02:42:47 +08:00
|
|
|
User.where(approved: false).update_all(approved: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
if name == :emoji_set
|
|
|
|
Emoji.clear_cache
|
|
|
|
|
2019-04-18 23:48:01 +08:00
|
|
|
before = "/images/emoji/#{old_value}/"
|
|
|
|
after = "/images/emoji/#{new_value}/"
|
2019-04-17 02:42:47 +08: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
|
|
|
|
|
|
|
|
Jobs.enqueue(:update_s3_inventory) if [:s3_inventory, :s3_upload_bucket].include?(name)
|
|
|
|
|
|
|
|
SvgSprite.expire_cache if name.to_s.include?("_icon")
|
2019-05-01 21:44:45 +08:00
|
|
|
|
|
|
|
if SiteIconManager::WATCHED_SETTINGS.include?(name)
|
|
|
|
SiteIconManager.ensure_optimized!
|
|
|
|
end
|
2019-04-17 02:42:47 +08:00
|
|
|
end
|