Class: StreamNotificationsJob

Inherits:
Hyrax::ApplicationJob show all
Defined in:
app/jobs/stream_notifications_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(users) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'app/jobs/stream_notifications_job.rb', line 3

def perform(users)
  # Do not use the ActionCable machinery if the feature is disabled
  return unless Hyrax.config.realtime_notifications?
  Array.wrap(users).each do |user|
    mailbox = UserMailbox.new(user)
    Hyrax::NotificationsChannel.broadcast_to(user,
                                             notifications_count: mailbox.unread_count,
                                             notifications_label: mailbox.label)
  end
end