Files
fizzy/app/models/notifier.rb
T
Kevin McConnell bc5e32e737 Only "published" notifies collection subscribers
The other notifications are only sent to the watchers of the bubble.
2025-03-18 17:46:57 +00:00

41 lines
680 B
Ruby

class Notifier
attr_reader :event
delegate :creator, to: :event
class << self
def for(event)
"Notifier::#{event.action.classify}".safe_constantize&.new(event)
end
end
def generate
if should_notify?
recipients.map do |recipient|
Notification.create! user: recipient, event: event, bubble: bubble, resource: resource
end
end
end
private
def initialize(event)
@event = event
end
def should_notify?
!event.creator.system?
end
def recipients
bubble.watchers.without(creator)
end
def resource
bubble
end
def bubble
event.summary.message.bubble
end
end