Skip to content

Commit

Permalink
fix: no need to verify action cable commands
Browse files Browse the repository at this point in the history
Action Cable now raises an exception in case command is unknown
  • Loading branch information
palkan committed Sep 13, 2024
1 parent 5f18be2 commit 34ac073
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions lib/anycable/rails/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ module AnyCable
module Rails
class Connection
class Subscriptions < ::ActionCable::Connection::Subscriptions
COMMANDS = %w[subscribe unsubscribe message].freeze

# Wrap the original #execute_command to pre-initialize the channel for unsubscribe/message and
# return true/false to indicate successful/unsuccessful subscription.
def execute_command(data)
cmd = data["command"]
return false unless COMMANDS.include?(cmd)

load(data["identifier"]) unless cmd == "subscribe"

Expand Down

0 comments on commit 34ac073

Please sign in to comment.