Files
fizzy/app/models/notification/push/web.rb
T
Rosa Gutierrez 05819f84a2 Refactor notification push system with registry pattern
Replace NotificationPusher with a cleaner architecture:

- Add Notification::Pushable concern with push target registry
- Add Notification::Push base class with template methods
- Add Notification::Push::Web for web push (OSS)
- Add Notification::Push::Native for native push (SaaS)
- Add Notification::WebPushJob and Notification::NativePushJob

Key design:
- Registry pattern: Notification.register_push_target(:web)
- Template method: push calls should_push? then perform_push
- Subclasses override should_push? (with super) and perform_push
- Each target handles its own job enqueueing

Also:
- Add Notification#pushable? for checking push eligibility
- Add Notification#identity delegation to user
- Reorganize tests to match new class structure

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Tidy up saas engine a bit more
2026-02-25 19:31:13 +01:00

19 lines
429 B
Ruby

class Notification::Push::Web < Notification::Push
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(build_payload, subscriptions)
end
def subscriptions
@subscriptions ||= notification.user.push_subscriptions
end
end