Class: SwitchboardChannel
- Inherits:
-
ApplicationCable::Channel
- Object
- ActionCable::Channel::Base
- ApplicationCable::Channel
- SwitchboardChannel
- Defined in:
- app/channels/switchboard_channel.rb
Overview
Delivers switchboard status cards only for employees on the viewer's watch
list. Stream selection happens on the server so a client cannot subscribe to
another employee by changing the cable element's attributes.
Instance Method Summary collapse
-
#subscribed ⇒ void
Authorizes the viewer and starts one internal stream per watched employee.
Methods inherited from ApplicationCable::Channel
Instance Method Details
#subscribed ⇒ void
This method returns an undefined value.
Authorizes the viewer and starts one internal stream per watched employee.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/channels/switchboard_channel.rb', line 10 def subscribed viewer = current_account&.party return reject unless viewer.is_a?(Employee) ability = CrmAbility.new(viewer) return reject unless ability.can?(:read, EmployeePhoneStatus) can_manage = ability.can?(:manage, EmployeePhoneStatus) stream_from EmployeePhoneStatus::BroadcastSwitchboard.refresh_stream_name(can_manage:) viewer.effective_watch_list_ids.each do |employee_id| stream_from EmployeePhoneStatus.switchboard_stream_name(employee_id, can_manage:) end end |