discourse/config/initializers/04-message_bus.rb

35 lines
894 B
Ruby
Raw Normal View History

2013-02-26 00:42:20 +08:00
MessageBus.site_id_lookup do
2013-02-06 03:16:51 +08:00
RailsMultisite::ConnectionManagement.current_db
end
MessageBus.user_id_lookup do |env|
2013-02-15 16:23:40 +08:00
user = CurrentUser.lookup_from_env(env)
2013-02-06 03:16:51 +08:00
user.id if user
end
MessageBus.on_connect do |site_id|
RailsMultisite::ConnectionManagement.establish_connection(:db => site_id)
end
MessageBus.on_disconnect do |site_id|
ActiveRecord::Base.connection_handler.clear_active_connections!
end
# Point at our redis
MessageBus.redis_config = YAML::load(File.open("#{Rails.root}/config/redis.yml"))[Rails.env].symbolize_keys
MessageBus.long_polling_enabled = SiteSetting.enable_long_polling
MessageBus.long_polling_interval = SiteSetting.long_polling_interval
2013-02-15 16:23:40 +08:00
2013-02-26 00:42:20 +08:00
MessageBus.is_admin_lookup do |env|
2013-02-15 16:23:40 +08:00
user = CurrentUser.lookup_from_env(env)
if user && user.admin
true
else
false
end
end
MessageBus.cache_assets = !Rails.env.development?
2013-02-16 09:14:52 +08:00
MessageBus.enable_diagnostics