Sha256: 3730c0bf542d5090bfaef4c7eb3aa962e3f1682dac79293e1b4a26d45d1ba6de

Contents?: true

Size: 986 Bytes

Versions: 16

Compression:

Stored size: 986 Bytes

Contents

module Marty
  module Notifications
    module Create
      extend Delorean::Functions

      delorean_fn :call do |event_type:, text:|
        notification, deliveries = ActiveRecord::Base.transaction do
          notification = ::Marty::Notifications::Notification.create!(
            event_type: event_type,
            text: text,
            state: :pending
          )

          # FIXME: We should consider processing deliveries in the background
          deliveries = ::Marty::Notifications::CreateDeliveries.call(
            notification: notification
          )

          [notification, deliveries]
        end

        deliveries.each do |delivery|
          ::Marty::Notifications::ProcessDelivery.call(
            delivery: delivery
          )
        end

        notification.set_processed!

        {
          id: notification.id,
          event_type: event_type,
          text: text,
          state: notification.state,
        }
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
marty-14.3.0 app/services/marty/notifications/create.rb
marty-14.0.0 app/services/marty/notifications/create.rb
marty-13.0.2 app/services/marty/notifications/create.rb
marty-11.0.0 app/services/marty/notifications/create.rb
marty-10.0.3 app/services/marty/notifications/create.rb
marty-10.0.2 app/services/marty/notifications/create.rb
marty-10.0.0 app/services/marty/notifications/create.rb
marty-9.5.1 app/services/marty/notifications/create.rb
marty-9.5.0 app/services/marty/notifications/create.rb
marty-9.3.3 app/services/marty/notifications/create.rb
marty-9.3.2 app/services/marty/notifications/create.rb
marty-9.3.0 app/services/marty/notifications/create.rb
marty-8.5.0 app/services/marty/notifications/create.rb
marty-8.4.1 app/services/marty/notifications/create.rb
marty-8.3.1 app/services/marty/notifications/create.rb
marty-8.2.0 app/services/marty/notifications/create.rb