mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:38 -06:00
BUGFIX: fix redirect, correct multisite
This commit is contained in:
parent
d1f0dda636
commit
50a0c1a751
@ -23,13 +23,13 @@ class UserAvatarsController < ApplicationController
|
||||
def show
|
||||
# we need multisite support to keep a single origin pull for CDNs
|
||||
RailsMultisite::ConnectionManagement.with_hostname(params[:hostname]) do
|
||||
show_in_site
|
||||
show_in_site(RailsMultisite::ConnectionManagement.current_hostname)
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def show_in_site
|
||||
def show_in_site(hostname)
|
||||
username = params[:username].to_s
|
||||
return render_dot unless user = User.find_by(username_lower: username.downcase)
|
||||
|
||||
@ -47,7 +47,7 @@ class UserAvatarsController < ApplicationController
|
||||
upload ||= user.uploaded_avatar if user.uploaded_avatar_id == version
|
||||
|
||||
if user.uploaded_avatar && !upload
|
||||
return redirect_to "/avatar/#{user.username_lower}/#{size}/#{user.uploaded_avatar_id}.png"
|
||||
return redirect_to "/avatar/#{hostname}/#{user.username_lower}/#{size}/#{user.uploaded_avatar_id}.png"
|
||||
elsif upload
|
||||
original = Discourse.store.path_for(upload)
|
||||
if Discourse.store.external? || File.exists?(original)
|
||||
|
@ -48,13 +48,13 @@ module RailsMultisite
|
||||
old = current_hostname
|
||||
connected = ActiveRecord::Base.connection_pool.connected?
|
||||
|
||||
establish_connection(:hostname => hostname) unless connected && hostname == old
|
||||
establish_connection(:host => hostname) unless connected && hostname == old
|
||||
rval = yield hostname
|
||||
|
||||
unless connected && hostname == old
|
||||
ActiveRecord::Base.connection_handler.clear_active_connections!
|
||||
|
||||
establish_connection(:hostname => old)
|
||||
establish_connection(:host => old)
|
||||
ActiveRecord::Base.connection_handler.clear_active_connections! unless connected
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user