nuntius 1.3.7 → 1.3.8
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 +14 -3
- data/app/{runners/nuntius/timebased_events_runner.rb → jobs/nuntius/timebased_events_job.rb} +1 -1
- data/app/messengers/nuntius/base_messenger.rb +2 -1
- data/app/presenters/template_presenter.rb +1 -1
- data/app/views/nuntius/admin/templates/edit.html.slim +2 -2
- data/lib/nuntius/configuration.rb +0 -1
- data/lib/nuntius/version.rb +1 -1
- metadata +3 -5
- data/app/runners/nuntius/application_runner.rb +0 -6
- data/app/runners/nuntius/basic_application_runner.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af9d9733e3d00160f1bc577fcfebcf92ce187f5ec1c24f0275234db388c73a6e
|
4
|
+
data.tar.gz: fedc019067d2fa07b1d870efc98c37201b38994246f2458a8d6fa9b42f54f0c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3df6eee0f723825cdbfa9d6b32ed96e5f51eb95169022138f0dd51cd1ae930eb3e6855ae8cb3c2d958d9720ac5edae2868c12693107bff7b7ebda893665e7c72
|
7
|
+
data.tar.gz: ac2e65dad9eba341791de05f4f921b4568924c8fc5e14d2b832c114cb8625e19868a29b60ac9414ba698a93595349fc0630f39b2ebedf59ccdc0dba39226efaf
|
data/README.md
CHANGED
@@ -55,7 +55,7 @@ class Car < ApplicationRecord
|
|
55
55
|
end
|
56
56
|
```
|
57
57
|
|
58
|
-
Additionally you need to define an extension of the Nuntius::BaseMessenger for the same model with a matching name (in app/messengers)
|
58
|
+
Additionally you need to define an extension of the Nuntius::BaseMessenger for the same model with a matching name (in app/messengers). Messengers can set extra parameters, but also manipulate templates selected.
|
59
59
|
|
60
60
|
```ruby
|
61
61
|
class CarMessenger < Nuntius::BaseMessenger
|
@@ -105,6 +105,11 @@ timebased_scope class method like so:
|
|
105
105
|
class CarMessenger < Nuntius::BaseMessenger
|
106
106
|
# time_range is a range, for a before scope the time_range the interval is added to the current
|
107
107
|
# time, the end of the range is 1 hour from the start.
|
108
|
+
#
|
109
|
+
# So say the interval is "10 days", the timerange will be:
|
110
|
+
# from: today + 10 days - 1 hour
|
111
|
+
# until: today + 10 days
|
112
|
+
# So it basically selects all Car's with a tuneup_at within 10 days from now (in a 1 hour window)
|
108
113
|
timebased_scope :before_tuneup do |time_range, metadata|
|
109
114
|
cars = Car.where(tuneup_at: time_range)
|
110
115
|
cars = cars.where(color: metadata['color']) if metadata['color'].present?
|
@@ -113,6 +118,11 @@ class CarMessenger < Nuntius::BaseMessenger
|
|
113
118
|
|
114
119
|
# For an after scope the time_range the interval is taken from the current time, the end of the
|
115
120
|
# range is 1 hour from its start.
|
121
|
+
#
|
122
|
+
# So say the interval is "10 days", the timerange will be:
|
123
|
+
# from: today - 10 days - 1 hour
|
124
|
+
# until: today - 10 days
|
125
|
+
# So it basically selects all Car's with a tuneup_at 10 days since now (in a 1 hour window)
|
116
126
|
timebased_scope :after_tuneup do |time_range, metadata|
|
117
127
|
cars = Car.where(tuneup_at: time_range)
|
118
128
|
cars = cars.where(color: metadata['color']) if metadata['color'].present?
|
@@ -131,8 +141,9 @@ following formats:
|
|
131
141
|
- N week(s)
|
132
142
|
- N month(s)
|
133
143
|
|
134
|
-
To send timebased messages you need to execute Nuntius::
|
135
|
-
in a cronjob every 5 minutes with "bundle exec rails runner Nuntius::
|
144
|
+
To send timebased messages you need to execute Nuntius::TimebasedEventsJob.perform, you could do this
|
145
|
+
in a cronjob every 5 minutes with "bundle exec rails runner 'Nuntius::TimebasedEventsJob.perform'".
|
146
|
+
Beter even is using Sidekiq::Cron or GoodJob
|
136
147
|
|
137
148
|
### Direct
|
138
149
|
|
data/app/{runners/nuntius/timebased_events_runner.rb → jobs/nuntius/timebased_events_job.rb}
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Nuntius
|
4
|
-
class
|
4
|
+
class TimebasedEventsJob < ApplicationJob
|
5
5
|
def perform
|
6
6
|
Nuntius::Template.where.not(interval: nil).each do |template|
|
7
7
|
messenger = Nuntius::BaseMessenger.messenger_for_class(template.klass)
|
@@ -9,7 +9,8 @@ module Nuntius
|
|
9
9
|
|
10
10
|
define_callbacks :action, terminator: ->(_target, result_lambda) { result_lambda.call == false }
|
11
11
|
|
12
|
-
attr_reader :
|
12
|
+
attr_reader :attachments, :event, :object, :params
|
13
|
+
attr_accessor :templates
|
13
14
|
|
14
15
|
def initialize(object, event, params = {})
|
15
16
|
@object = object
|
@@ -9,7 +9,7 @@ class TemplatePresenter < ApplicationPresenter
|
|
9
9
|
messenger = Nuntius::BaseMessenger.messenger_for_class(class_name)
|
10
10
|
messenger.instance_methods(false).each do |m|
|
11
11
|
events << [m, m, {"data-chain": class_name,
|
12
|
-
"data-timebased": messenger.timebased_scopes.include?(m)}]
|
12
|
+
"data-timebased": messenger.timebased_scopes.include?(m) ? "Y" : "N"}]
|
13
13
|
end
|
14
14
|
end
|
15
15
|
events.sort_by(&:first)
|
@@ -21,12 +21,12 @@
|
|
21
21
|
.col-span-6 data-toggle-target="insertion"
|
22
22
|
|
23
23
|
template data-toggle-target='toggleable' data-toggle-not-value='Custom'
|
24
|
-
.col-span-6
|
24
|
+
.col-span-6 data-controller='toggle' data-toggle-attr='data-timebased'
|
25
25
|
.grid.grid-cols-12.gap-4
|
26
26
|
.col-span-6
|
27
27
|
= f.input :event, collection: template.all_events, include_blank: false, chain_to: 'template[klass]', input_html: { data: { 'toggle-target' => 'input' } }, as: :dropdown
|
28
28
|
.col-span-6 data-toggle-target="insertion"
|
29
|
-
template data-toggle-target='toggleable' data-toggle-value='
|
29
|
+
template data-toggle-target='toggleable' data-toggle-value='Y'
|
30
30
|
= f.input :interval
|
31
31
|
|
32
32
|
template data-toggle-target='toggleable' data-toggle-value='Custom'
|
@@ -41,7 +41,6 @@ module Nuntius
|
|
41
41
|
option :logger, default: -> { Rails.logger }, proc: true
|
42
42
|
option :admin_authentication_module, default: "Auxilium::Concerns::AdminAuthenticated"
|
43
43
|
option :base_controller, default: "::ApplicationController"
|
44
|
-
option :base_runner, default: "Nuntius::BasicApplicationRunner"
|
45
44
|
option :layout, default: "application"
|
46
45
|
option :admin_layout, default: "application"
|
47
46
|
option :jobs_queue_name, default: "message"
|
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.3.
|
4
|
+
version: 1.3.8
|
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: 2024-
|
11
|
+
date: 2024-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apnotic
|
@@ -459,6 +459,7 @@ files:
|
|
459
459
|
- app/jobs/nuntius/messenger_job.rb
|
460
460
|
- app/jobs/nuntius/purge_message_job.rb
|
461
461
|
- app/jobs/nuntius/retrieve_mail_job.rb
|
462
|
+
- app/jobs/nuntius/timebased_events_job.rb
|
462
463
|
- app/jobs/nuntius/transport_delivery_job.rb
|
463
464
|
- app/jobs/nuntius/transport_refresh_job.rb
|
464
465
|
- app/message_boxes/nuntius/base_message_box.rb
|
@@ -488,9 +489,6 @@ files:
|
|
488
489
|
- app/providers/nuntius/teams_teams_provider.rb
|
489
490
|
- app/providers/nuntius/twilio_sms_provider.rb
|
490
491
|
- app/providers/nuntius/twilio_voice_provider.rb
|
491
|
-
- app/runners/nuntius/application_runner.rb
|
492
|
-
- app/runners/nuntius/basic_application_runner.rb
|
493
|
-
- app/runners/nuntius/timebased_events_runner.rb
|
494
492
|
- app/services/nuntius/application_service.rb
|
495
493
|
- app/services/nuntius/aws_sns_processor_service.rb
|
496
494
|
- app/services/nuntius/deliver_campaign_service.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nuntius
|
4
|
-
# This is the default runner used for runners in Nuntius, you can insert your
|
5
|
-
# own in the Nuntius configuration in your Rails Nuntius initializer.
|
6
|
-
class BasicApplicationRunner
|
7
|
-
def call
|
8
|
-
perform
|
9
|
-
end
|
10
|
-
|
11
|
-
class << self
|
12
|
-
delegate :call, to: :new
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|