Create ActionCable channel for guest chat subscriptions
Backlog
Subtask
High
Description
## Task
Create an ActionCable channel that allows unauthenticated guests to subscribe to chat messages for their support session.
## Why ActionCable?
- Guests have no NATS device/authentication
- Need WebSocket for real-time without polling
- ActionCable is already available in Rails stack
- Can authenticate via session token in connection params
## Channel Design
```ruby
# app/channels/support_session_chat_channel.rb
class SupportSessionChatChannel < ApplicationCable::Channel
def subscribed
session = find_session_by_token(params[:token])
if session&.can_join?
stream_from "support_session_chat:#{session.id}"
@session = session
else
reject
end
end
def unsubscribed
stop_all_streams
end
def receive(data)
# Handle incoming messages from WebSocket
# Validate and save via SendChatMessageService
end
end
```
## Connection Authentication
Modify `ApplicationCable::Connection` to support token-based auth for guests (in addition to existing user auth).
## Broadcast Integration
Update `SendChatMessageService` to broadcast via:
```ruby
ActionCable.server.broadcast(
"support_session_chat:#{session.id}",
message.to_broadcast_payload
)
```
## Files to Create/Modify
- `app/channels/support_session_chat_channel.rb`
- `app/channels/application_cable/connection.rb` (modify for guest tokens)
- `spec/channels/support_session_chat_channel_spec.rb`
Working Memory
{
"blocked_reason": "Waiting for dependencies: 101"
}
Ticket Stats
Status:
Backlog
Priority:
High
Type:
Subtask
Comments
0 commentsAdd a Comment
No Subtasks Yet
Break down this ticket into smaller, manageable subtasks