nuntius 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/jobs/nuntius/messenger_job.rb +18 -6
- data/app/models/nuntius/concerns/events_transaction.rb +31 -0
- data/app/models/nuntius/event.rb +6 -0
- data/db/migrate/20250520091916_create_nuntius_events_table.rb +12 -0
- data/lib/nuntius/active_record_helpers.rb +1 -0
- data/lib/nuntius/version.rb +1 -1
- metadata +7 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: be4761123ee4a2d8aaca7f70592b66c3f0f2c1a352596e10233f9e1f7fae1d82
         | 
| 4 | 
            +
              data.tar.gz: 4a725d5bfa7f330ac1a7b89955b7df2aef3a56ee1ee36a8ea1a85074f26a6d77
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 108cc9efe6c26d6cc223fe9c58f671bbfc95ac4992c1859feca5d9f4d718eab4811b60d045b04cec06595bfcdc77ecf18e391dce0de87a8cce6388c52cb98b94
         | 
| 7 | 
            +
              data.tar.gz: afffc5c56327a134603c24520727ee9d1b76b527a1e378de6c350d71f459e488e8238c8dda9bf4ea562ce1b12107aa4d6bda3349109bafbc92f23815cb5abc8a
         | 
    
        data/README.md
    CHANGED
    
    | @@ -150,7 +150,7 @@ in a cronjob every 5 minutes with "bundle exec rails runner 'Nuntius::TimebasedE | |
| 150 150 | 
             
            Beter even is using Sidekiq::Cron or GoodJob
         | 
| 151 151 |  | 
| 152 152 | 
             
            Nuntius will automatically prevent sending duplicates within the timerange you define. 
         | 
| 153 | 
            -
            It will also ONLY send messages for objects (the one in template class), created after you created this template.
         | 
| 153 | 
            +
            It will also ONLY send messages for objects (the one in template class), created after you created this template, this prevents sending dozens of emails which may make no sense, when you add a new template.
         | 
| 154 154 |  | 
| 155 155 | 
             
            ### Direct
         | 
| 156 156 |  | 
| @@ -5,15 +5,27 @@ module Nuntius | |
| 5 5 | 
             
              class MessengerJob < ApplicationJob
         | 
| 6 6 | 
             
                def perform(obj, event, params = {})
         | 
| 7 7 | 
             
                  return unless obj
         | 
| 8 | 
            +
                  ActiveRecord::Base.transaction do
         | 
| 9 | 
            +
                    messenger = Nuntius::BaseMessenger.messenger_for_obj(obj).new(obj, event, params)
         | 
| 10 | 
            +
                    return unless messenger.is_a?(Nuntius::CustomMessenger) || messenger.respond_to?(event.to_sym)
         | 
| 8 11 |  | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 12 | 
            +
                    result = messenger.call
         | 
| 13 | 
            +
                    return if result == false
         | 
| 11 14 |  | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 15 | 
            +
                    templates = messenger.templates
         | 
| 16 | 
            +
                    messenger.dispatch(templates) if templates.present?
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
                  cleanup_nuntius_events(obj, event)
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                def cleanup_nuntius_events(obj, event)
         | 
| 14 22 |  | 
| 15 | 
            -
                   | 
| 16 | 
            -
             | 
| 23 | 
            +
                  nuntius_events = Nuntius::Event.where(
         | 
| 24 | 
            +
                    transitionable_id: obj["id"],
         | 
| 25 | 
            +
                    transitionable_type: obj["type"],
         | 
| 26 | 
            +
                    transition_event: event.to_s
         | 
| 27 | 
            +
                  )
         | 
| 28 | 
            +
                  nuntius_events.destroy_all
         | 
| 17 29 | 
             
                end
         | 
| 18 30 | 
             
              end
         | 
| 19 31 | 
             
            end
         | 
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            module Nuntius
         | 
| 2 | 
            +
              module Concerns
         | 
| 3 | 
            +
                module EventsTransaction
         | 
| 4 | 
            +
                  extend ActiveSupport::Concern
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  included do
         | 
| 7 | 
            +
                    state_machine do
         | 
| 8 | 
            +
                      after_transition any => any do |record, transition|
         | 
| 9 | 
            +
                        event = Nuntius::Event.find_or_initialize_by(
         | 
| 10 | 
            +
                          transitionable_id: record.id,
         | 
| 11 | 
            +
                          transitionable_type: record.class.to_s,
         | 
| 12 | 
            +
                          transition_event: transition.event.to_s,
         | 
| 13 | 
            +
                          transition_attribute: transition.attribute.to_s
         | 
| 14 | 
            +
                        )
         | 
| 15 | 
            +
                        event.update!(
         | 
| 16 | 
            +
                          transition_from: transition.from.to_s,
         | 
| 17 | 
            +
                          transition_to: transition.to.to_s
         | 
| 18 | 
            +
                        )
         | 
| 19 | 
            +
                      end
         | 
| 20 | 
            +
                    end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                    after_commit do
         | 
| 23 | 
            +
                      Nuntius::Event.all.each do |transition|
         | 
| 24 | 
            +
                        transitionable = transition.transitionable_type.constantize.find(transition.transitionable_id)
         | 
| 25 | 
            +
                        Nuntius.event(transition.transition_event.to_sym, transitionable)
         | 
| 26 | 
            +
                      end
         | 
| 27 | 
            +
                    end
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
| @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            class CreateNuntiusEventsTable < ActiveRecord::Migration[7.0]
         | 
| 2 | 
            +
              def change
         | 
| 3 | 
            +
                create_table :nuntius_events do |t|
         | 
| 4 | 
            +
                  t.references :transitionable, type: :uuid, polymorphic: true
         | 
| 5 | 
            +
                  t.string :transition_attribute
         | 
| 6 | 
            +
                  t.string :transition_event
         | 
| 7 | 
            +
                  t.string :transition_from
         | 
| 8 | 
            +
                  t.string :transition_to
         | 
| 9 | 
            +
                  t.timestamps
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
            end
         | 
| @@ -18,6 +18,7 @@ module Nuntius::ActiveRecordHelpers | |
| 18 18 | 
             
                  @_nuntius_nuntiable_options = options
         | 
| 19 19 | 
             
                  include Nuntius::Nuntiable
         | 
| 20 20 | 
             
                  include Nuntius::StateMachine if options[:use_state_machine]
         | 
| 21 | 
            +
                  include Nuntius::Concerns::EventsTransaction if options[:use_state_machine]
         | 
| 21 22 | 
             
                  include Nuntius::Devise if options[:override_devise]
         | 
| 22 23 | 
             
                  include Nuntius::LifeCycle if options[:life_cycle]
         | 
| 23 24 | 
             
                end
         | 
    
        data/lib/nuntius/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: nuntius
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.4. | 
| 4 | 
            +
              version: 1.4.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Tom de Grunt
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2025- | 
| 11 | 
            +
            date: 2025-05-20 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: apnotic
         | 
| @@ -156,14 +156,14 @@ dependencies: | |
| 156 156 | 
             
                requirements:
         | 
| 157 157 | 
             
                - - "~>"
         | 
| 158 158 | 
             
                  - !ruby/object:Gem::Version
         | 
| 159 | 
            -
                    version:  | 
| 159 | 
            +
                    version: 1.2.1
         | 
| 160 160 | 
             
              type: :runtime
         | 
| 161 161 | 
             
              prerelease: false
         | 
| 162 162 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 163 163 | 
             
                requirements:
         | 
| 164 164 | 
             
                - - "~>"
         | 
| 165 165 | 
             
                  - !ruby/object:Gem::Version
         | 
| 166 | 
            -
                    version:  | 
| 166 | 
            +
                    version: 1.2.1
         | 
| 167 167 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 168 168 | 
             
              name: mail
         | 
| 169 169 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -481,8 +481,10 @@ files: | |
| 481 481 | 
             
            - app/models/nuntius/application_record.rb
         | 
| 482 482 | 
             
            - app/models/nuntius/attachment.rb
         | 
| 483 483 | 
             
            - app/models/nuntius/campaign.rb
         | 
| 484 | 
            +
            - app/models/nuntius/concerns/events_transaction.rb
         | 
| 484 485 | 
             
            - app/models/nuntius/concerns/metadata_scoped.rb
         | 
| 485 486 | 
             
            - app/models/nuntius/concerns/yamlify.rb
         | 
| 487 | 
            +
            - app/models/nuntius/event.rb
         | 
| 486 488 | 
             
            - app/models/nuntius/inbound_message.rb
         | 
| 487 489 | 
             
            - app/models/nuntius/layout.rb
         | 
| 488 490 | 
             
            - app/models/nuntius/list.rb
         | 
| @@ -569,6 +571,7 @@ files: | |
| 569 571 | 
             
            - db/migrate/20220412114148_add_last_sent_to_message.rb
         | 
| 570 572 | 
             
            - db/migrate/20240205204719_add_description_to_list.rb
         | 
| 571 573 | 
             
            - db/migrate/20240206203019_add_slug_to_nuntius_list.rb
         | 
| 574 | 
            +
            - db/migrate/20250520091916_create_nuntius_events_table.rb
         | 
| 572 575 | 
             
            - lib/generators/nuntius/install_generator.rb
         | 
| 573 576 | 
             
            - lib/generators/nuntius/tailwind_config_generator.rb
         | 
| 574 577 | 
             
            - lib/generators/nuntius/templates/config/initializers/nuntius.rb
         |