diff --git a/app/channels/activity_notification/notification_api_channel.rb b/app/channels/activity_notification/notification_api_channel.rb index ce2eca61..8d209e78 100644 --- a/app/channels/activity_notification/notification_api_channel.rb +++ b/app/channels/activity_notification/notification_api_channel.rb @@ -1,8 +1,8 @@ -if defined?(ActionCable) - # Action Cable API channel to subscribe broadcasted notifications. - class ActivityNotification::NotificationApiChannel < ActivityNotification::NotificationChannel - # ActionCable::Channel::Base#subscribed - # @see https://api.rubyonrails.org/classes/ActionCable/Channel/Base.html#method-i-subscribed +# Action Cable API channel to subscribe broadcasted notifications. +class ActivityNotification::NotificationApiChannel < ActivityNotification::NotificationChannel + if defined?(ActionCable) + # ActionCable::Channel::Base#subscribed + # @see https://api.rubyonrails.org/classes/ActionCable/Channel/Base.html#method-i-subscribed def subscribed stream_from "#{ActivityNotification.config.notification_api_channel_prefix}_#{@target.to_class_name}#{ActivityNotification.config.composite_key_delimiter}#{@target.id}" rescue diff --git a/app/channels/activity_notification/notification_api_with_devise_channel.rb b/app/channels/activity_notification/notification_api_with_devise_channel.rb index 759c8a44..1a4fde17 100644 --- a/app/channels/activity_notification/notification_api_with_devise_channel.rb +++ b/app/channels/activity_notification/notification_api_with_devise_channel.rb @@ -1,6 +1,6 @@ -if defined?(ActionCable) - # Action Cable API channel to subscribe broadcasted notifications with Devise authentication. - class ActivityNotification::NotificationApiWithDeviseChannel < ActivityNotification::NotificationApiChannel +# Action Cable API channel to subscribe broadcasted notifications with Devise authentication. +class ActivityNotification::NotificationApiWithDeviseChannel < ActivityNotification::NotificationApiChannel + if defined?(ActionCable) # Include PolymorphicHelpers to resolve string extentions include ActivityNotification::PolymorphicHelpers diff --git a/app/channels/activity_notification/notification_channel.rb b/app/channels/activity_notification/notification_channel.rb index 40f5d2ea..c26a3190 100644 --- a/app/channels/activity_notification/notification_channel.rb +++ b/app/channels/activity_notification/notification_channel.rb @@ -34,4 +34,6 @@ def authenticate_target! reject if @target.nil? || @target.notification_action_cable_with_devise? end end +else + class ActivityNotification::NotificationChannel; end end diff --git a/app/channels/activity_notification/notification_with_devise_channel.rb b/app/channels/activity_notification/notification_with_devise_channel.rb index 2c4b8d3e..c8967c01 100644 --- a/app/channels/activity_notification/notification_with_devise_channel.rb +++ b/app/channels/activity_notification/notification_with_devise_channel.rb @@ -1,6 +1,6 @@ -if defined?(ActionCable) - # Action Cable channel to subscribe broadcasted notifications with Devise authentication. - class ActivityNotification::NotificationWithDeviseChannel < ActivityNotification::NotificationChannel +# Action Cable channel to subscribe broadcasted notifications with Devise authentication. +class ActivityNotification::NotificationWithDeviseChannel < ActivityNotification::NotificationChannel + if defined?(ActionCable) # Include PolymorphicHelpers to resolve string extentions include ActivityNotification::PolymorphicHelpers