about summary refs log tree commit diff
path: root/app/services/notify_service.rb
diff options
context:
space:
mode:
authorSorin Davidoi <sorin.davidoi@gmail.com>2017-07-18 16:25:40 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-07-18 16:25:40 +0200
commit8387b3928ec7658192907da79df65e65aaa8a7fc (patch)
tree87df6e1941444eae5ae44856cd0f2e4e857213ac /app/services/notify_service.rb
parentafa52e4d636f8fdc4b21b90e4f006d8ea434b4e9 (diff)
fix(push-subscriptions): Refactor how Sidekiq jobs are handled (#4226)
Diffstat (limited to 'app/services/notify_service.rb')
-rw-r--r--app/services/notify_service.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/services/notify_service.rb b/app/services/notify_service.rb
index 0ab61b634..c7d8ad50a 100644
--- a/app/services/notify_service.rb
+++ b/app/services/notify_service.rb
@@ -65,7 +65,11 @@ class NotifyService < BaseService
   end
 
   def send_push_notifications
-    WebPushNotificationWorker.perform_async(@recipient.id, @notification.id)
+    sessions_with_subscriptions_ids = @recipient.user.session_activations.where.not(web_push_subscription: nil).pluck(:id)
+
+    WebPushNotificationWorker.push_bulk(sessions_with_subscriptions_ids) do |session_activation_id|
+      [session_activation_id, @notification.id]
+    end
   end
 
   def send_email