ActionCable: use find method when unsubscribing

If a frontend for some reason tries to unsubscribe from a non existing subscription, the following error is logged:

Could not execute command from ({"command"=>"unsubscribe", "identifier"=>"{\"channel\":\"SomeChannel\"}"}) [NoMethodError - undefined method `unsubscribe_from_channel' for nil:NilClass]

Instead, it will now properly log:

Could not execute command from ({"command"=>"unsubscribe", "identifier"=>"{\"channel\":\"SomeChannel\"}"}) [RuntimeError - Unable to find subscription with identifier: {"channel":"SomeChannel"}]
This commit is contained in:
Richard Machielse 2017-09-25 13:03:52 +02:00
parent 5755f57f3e
commit 4b629eca21
No known key found for this signature in database
GPG Key ID: 7B0AB0D4F3DAC0E8

@ -43,7 +43,7 @@ def add(data)
def remove(data)
logger.info "Unsubscribing from channel: #{data['identifier']}"
remove_subscription subscriptions[data["identifier"]]
remove_subscription find(data)
end
def remove_subscription(subscription)