mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-02-13 21:33:20 +01:00
Handle push notifications in Sidekiq job
This commit is contained in:
parent
185c454da0
commit
89008364d9
3 changed files with 20 additions and 0 deletions
|
@ -12,6 +12,8 @@ module User::PushNotificationMethods
|
|||
message: resource.as_push_notification.to_json
|
||||
}
|
||||
n.save!
|
||||
|
||||
PushNotificationWorker.perform_async(n.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
17
app/workers/push_notification_worker.rb
Normal file
17
app/workers/push_notification_worker.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "rpush/daemon"
|
||||
|
||||
class PushNotificationWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options queue: :push_notification, retry: 0
|
||||
|
||||
def perform(notification_id)
|
||||
Rpush.config.push = true
|
||||
Rpush::Daemon.common_init
|
||||
Rpush::Daemon::Synchronizer.sync
|
||||
Rpush::Daemon::AppRunner.enqueue(Rpush::Client::ActiveRecord::Notification.where(id: notification_id))
|
||||
Rpush::Daemon::AppRunner.stop
|
||||
end
|
||||
end
|
|
@ -12,4 +12,5 @@ production:
|
|||
- mailers
|
||||
- question
|
||||
- export
|
||||
- push_notification
|
||||
|
||||
|
|
Loading…
Reference in a new issue