mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
aa9b3bb35a
Added the site setting long_polling_base_url , this allows you to farm long polling to a different server. This setting is very important if a CDN is serving dynamic content.
47 lines
1.3 KiB
Ruby
47 lines
1.3 KiB
Ruby
MessageBus.site_id_lookup do
|
|
RailsMultisite::ConnectionManagement.current_db
|
|
end
|
|
|
|
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
|
|
|
|
MessageBus.user_id_lookup do |env|
|
|
user = CurrentUser.lookup_from_env(env)
|
|
user.id if user
|
|
end
|
|
|
|
MessageBus.group_ids_lookup do |env|
|
|
user = CurrentUser.lookup_from_env(env)
|
|
user.groups.select('groups.id').map{|g| g.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(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env].symbolize_keys
|
|
|
|
MessageBus.long_polling_enabled = SiteSetting.enable_long_polling
|
|
MessageBus.long_polling_interval = SiteSetting.long_polling_interval
|
|
|
|
MessageBus.is_admin_lookup do |env|
|
|
user = CurrentUser.lookup_from_env(env)
|
|
if user && user.admin
|
|
true
|
|
else
|
|
false
|
|
end
|
|
end
|
|
|
|
MessageBus.cache_assets = !Rails.env.development?
|
|
MessageBus.enable_diagnostics
|