Files
fizzy/app/models/notifier.rb
T
Kevin McConnell 0820badcc3 Add involvement types to accesses
This provides a way to set the level of involvement that a user has with
a collection, and from which we determine the level of notifications to
send. Users can be access-only, watching, or being notified about
everything.

If you're access-only, you won't get an notifications. If you're
watching, you'll only get notifications for the items you're watching
(which includes the items you've been assigned, have commented on, etc).
If you're set to everything you'll get notifications about all activity
in that collection.

This change replaces our previous concept of subscriptions. Where
previously you'd subscribe to a collection to get notifications in it,
now you'll simply set the notification level on your access.
2025-04-03 16:35:13 +01:00

41 lines
696 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_and_subscribers.without(creator)
end
def resource
bubble
end
def bubble
event.summary.message.bubble
end
end