b5205ce6b2
PushTarget#push reads more naturally than Push#push. The push target is the thing that pushes notifications to a specific destination. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
19 lines
453 B
Ruby
19 lines
453 B
Ruby
class Notification::PushTarget::Web < Notification::PushTarget
|
|
def self.push_later(notification)
|
|
Notification::WebPushJob.perform_later(notification)
|
|
end
|
|
|
|
private
|
|
def should_push?
|
|
super && subscriptions.any?
|
|
end
|
|
|
|
def perform_push
|
|
Rails.configuration.x.web_push_pool.queue(notification.payload.to_h, subscriptions)
|
|
end
|
|
|
|
def subscriptions
|
|
@subscriptions ||= notification.user.push_subscriptions
|
|
end
|
|
end
|