Consolidate push jobs into single Notification::PushJob
Replace separate WebPushJob and NativePushJob with a single PushJob that calls notification.push, which iterates over registered targets. Each target handles its own delivery - Web pushes synchronously via the pool, Native enqueues device-level jobs via deliver_later_to. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
class Notification::PushJob < ApplicationJob
|
||||
def perform(notification)
|
||||
notification.push
|
||||
end
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class Notification::WebPushJob < ApplicationJob
|
||||
def perform(notification)
|
||||
Notification::PushTarget::Web.new(notification).push
|
||||
end
|
||||
end
|
||||
@@ -1,8 +1,4 @@
|
||||
class Notification::PushTarget::Web < Notification::PushTarget
|
||||
def self.push_later(notification)
|
||||
Notification::WebPushJob.perform_later(notification)
|
||||
end
|
||||
|
||||
private
|
||||
def should_push?
|
||||
super && subscriptions.any?
|
||||
|
||||
@@ -24,8 +24,12 @@ module Notification::Pushable
|
||||
end
|
||||
|
||||
def push_later
|
||||
Notification::PushJob.perform_later(self)
|
||||
end
|
||||
|
||||
def push
|
||||
self.class.push_targets.each do |target|
|
||||
target.push_later(self)
|
||||
target.new(self).push
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user