Class: Collavre::CreativesChannel
- Inherits:
-
ApplicationCable::Channel
- Object
- ApplicationCable::Channel
- Collavre::CreativesChannel
- Defined in:
- app/channels/collavre/creatives_channel.rb
Instance Method Summary collapse
Instance Method Details
#editing(data) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/channels/collavre/creatives_channel.rb', line 23 def editing(data) return unless @root && current_user creative_id = data["creative_id"].to_i payload = { editing: { creative_id: creative_id, user_id: current_user.id, user_name: current_user.display_name, avatar_url: user_avatar_url_for(current_user) } } broadcast_to_all_ancestors(creative_id, payload) end |
#stopped_editing(data) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/channels/collavre/creatives_channel.rb', line 38 def stopped_editing(data) return unless @root && current_user creative_id = data["creative_id"].to_i payload = { stopped_editing: { creative_id: creative_id, user_id: current_user.id } } broadcast_to_all_ancestors(creative_id, payload) end |
#subscribed ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/channels/collavre/creatives_channel.rb', line 3 def subscribed return reject unless params[:root_id].present? && current_user @root = Creative.find_by(id: params[:root_id])&.effective_origin return reject unless @root return reject unless @root.(current_user, :read) Rails.logger.info "[CreativesChannel] User #{current_user.email} subscribed to root #{@root.id}" stream_for @root CreativePresenceStore.add(@root.id, current_user.id) broadcast_presence end |
#unsubscribed ⇒ Object
16 17 18 19 20 21 |
# File 'app/channels/collavre/creatives_channel.rb', line 16 def unsubscribed if @root && current_user CreativePresenceStore.remove(@root.id, current_user.id) broadcast_presence end end |