Files
fizzy/app/models/notifier.rb
T
Jorge Manrubia 40368032f2 Split notifiers for comments and cards
This lets us remove the annoying if to check the card
2025-04-24 15:19:42 +02:00

32 lines
588 B
Ruby

class Notifier
attr_reader :source
class << self
def for(source)
case source
when Event
"Notifier::#{source.eventable.class}EventNotifier".safe_constantize&.new(source)
when Mention
MentionNotifier.new(source)
end
end
end
def notify
if should_notify?
recipients.map do |recipient|
Notification.create! user: recipient, source: source, creator: creator
end
end
end
private
def initialize(source)
@source = source
end
def should_notify?
!creator.system?
end
end