Files
fizzy/app/models/bubble/eventable.rb
T
Kevin McConnell e6fe7f680d Associate Event with Bubble
It's kind of a long way to get from one to the other right now. Every
event belongs to a bubble, so let's link them directly.
2025-01-17 14:40:36 +00:00

20 lines
540 B
Ruby

module Bubble::Eventable
extend ActiveSupport::Concern
included do
has_many :events, dependent: :destroy
end
private
def track_event(action, creator: Current.user, **particulars)
event = find_or_capture_event_summary.events.create! action: action, creator: creator, bubble: self, particulars: particulars
event.generate_notifications_later
end
def find_or_capture_event_summary
transaction do
messages.last&.event_summary || capture(EventSummary.new).event_summary
end
end
end