FIX: improve error results for message bus failures

This commit is contained in:
Sam 2016-08-25 15:39:15 +10:00
parent bfefda06f6
commit 846a08d3c7
2 changed files with 9 additions and 1 deletions

View File

@ -156,7 +156,7 @@ GEM
mail (2.6.4)
mime-types (>= 1.16, < 4)
memory_profiler (0.9.6)
message_bus (2.0.1)
message_bus (2.0.2)
rack (>= 1.1.3)
metaclass (0.0.4)
method_source (0.8.2)

View File

@ -61,6 +61,14 @@ MessageBus.is_admin_lookup do |env|
env["__mb"][:is_admin]
end
MessageBus.on_middleware_error do |env, e|
if Discourse::InvalidAccess === e
[403, {}, ["Invalid Access"]]
elsif RateLimiter::LimitExceeded === e
[429, {}, [e.description]]
end
end
MessageBus.on_connect do |site_id|
RailsMultisite::ConnectionManagement.establish_connection(db: site_id)
end