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
|
|
|
|
|
2014-10-24 10:38:00 +08:00
|
|
|
MessageBus.extra_response_headers_lookup do |env|
|
|
|
|
{
|
|
|
|
"Access-Control-Allow-Origin" => Discourse.base_url,
|
|
|
|
"Access-Control-Allow-Methods" => "GET, POST",
|
|
|
|
"Access-Control-Allow-Headers" => "X-SILENCE-LOGGER, X-Shared-Session-Key"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
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
|
|
|
|
|
2013-05-16 13:03:03 +08:00
|
|
|
MessageBus.group_ids_lookup do |env|
|
|
|
|
user = CurrentUser.lookup_from_env(env)
|
|
|
|
user.groups.select('groups.id').map{|g| g.id} if user
|
|
|
|
end
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
MessageBus.on_connect do |site_id|
|
2013-03-23 23:02:59 +08:00
|
|
|
RailsMultisite::ConnectionManagement.establish_connection(db: site_id)
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
MessageBus.on_disconnect do |site_id|
|
|
|
|
ActiveRecord::Base.connection_handler.clear_active_connections!
|
|
|
|
end
|
|
|
|
|
|
|
|
# Point at our redis
|
2013-03-10 20:51:49 +08:00
|
|
|
MessageBus.redis_config = YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env].symbolize_keys
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
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
|