Files
fizzy/app/models/bubble/eventable.rb
T
2025-01-13 14:21:47 +00:00

20 lines
547 B
Ruby

module Bubble::Eventable
extend ActiveSupport::Concern
included do
after_create -> { track_event :created, creator: creator }
end
private
def track_event(action, creator: Current.user, **particulars)
event = find_or_capture_event_summary.events.create! action: action, creator: creator, 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