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