nuntius 1.3.6 → 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 +16 -3
- data/app/controllers/nuntius/admin/campaigns_controller.rb +1 -1
- data/app/controllers/nuntius/admin/layouts_controller.rb +5 -1
- 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/models/nuntius/campaign.rb +3 -0
- data/app/presenters/template_presenter.rb +1 -1
- data/app/providers/nuntius/smtp_mail_provider.rb +2 -2
- data/app/services/nuntius/deliver_campaign_service.rb +7 -3
- data/app/tables/nuntius/campaign_messages_table.rb +24 -0
- data/app/views/nuntius/admin/campaigns/edit.html.slim +5 -13
- data/app/views/nuntius/admin/layouts/edit.html.slim +3 -2
- data/app/views/nuntius/admin/templates/edit.html.slim +2 -2
- data/config/locales/en.yml +1 -0
- data/config/locales/nl.yml +1 -0
- data/lib/nuntius/configuration.rb +0 -1
- data/lib/nuntius/version.rb +1 -1
- metadata +4 -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
|
|
@@ -165,6 +176,8 @@ The main key of the hash passed will also be the liquid variable.
|
|
165
176
|
|
166
177
|
Outbound mail is handled through SMTP. We've only exposed the HTML of mail, we can create text-versions based on sanitized HTML. HTML allows for [Foundation for Emails](https://get.foundation/emails/docs/index.html). You will have to include the CSS in the layouts.
|
167
178
|
|
179
|
+
In the layout you can add `<a href="{{message_url}}">Link to mail</a>` to provide a link to the online version of the message.
|
180
|
+
|
168
181
|
#### AWS SES
|
169
182
|
|
170
183
|
In case you use AWS SES, you can use the SNS Feedback Notifications to automatically mark messages as read, or deal with complaints and bounces. Create a AWS SNS topic, with a HTTPS subscription with the following URL (pattern):
|
@@ -51,7 +51,7 @@ module Nuntius
|
|
51
51
|
def campaign_params
|
52
52
|
return unless params[:campaign]
|
53
53
|
|
54
|
-
params.require(:campaign).permit(:name, :transport, :layout_id, :list_id, :from, :subject, :text, :html)
|
54
|
+
params.require(:campaign).permit(:name, :transport, :layout_id, :list_id, :from, :subject, :text, :html, :metadata_yaml)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -31,6 +31,11 @@ module Nuntius
|
|
31
31
|
def update
|
32
32
|
@layout = Nuntius::Layout.visible.find(params[:id])
|
33
33
|
@layout.update(layout_params)
|
34
|
+
if params[:layout][:attachments].present?
|
35
|
+
params[:layout][:attachments].each do |attachment|
|
36
|
+
@layout.attachments.attach(attachment)
|
37
|
+
end
|
38
|
+
end
|
34
39
|
respond_with :admin, @layout
|
35
40
|
end
|
36
41
|
|
@@ -44,7 +49,6 @@ module Nuntius
|
|
44
49
|
|
45
50
|
def layout_params
|
46
51
|
permitted = %i[name data metadata_yaml]
|
47
|
-
permitted += [attachments: []] if params[:layout][:attachments].compact_blank.present?
|
48
52
|
params.require(:layout).permit(permitted)
|
49
53
|
end
|
50
54
|
end
|
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)
|
@@ -45,7 +45,7 @@ module Nuntius
|
|
45
45
|
charset: "UTF-8"
|
46
46
|
)
|
47
47
|
if message.html.present?
|
48
|
-
message.html = message.html.gsub("
|
48
|
+
message.html = message.html.gsub("{{message_url}}") { message_url(message) }
|
49
49
|
p.html_part = Mail::Part.new(
|
50
50
|
body: message.html,
|
51
51
|
content_type: "text/html",
|
@@ -84,7 +84,7 @@ module Nuntius
|
|
84
84
|
private
|
85
85
|
|
86
86
|
def message_url(message)
|
87
|
-
Nuntius::Engine.routes.url_helpers.message_url(message.id, host: Nuntius.config.host
|
87
|
+
Nuntius::Engine.routes.url_helpers.message_url(message.id, host: Nuntius.config.host(message))
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
@@ -11,7 +11,7 @@ module Nuntius
|
|
11
11
|
|
12
12
|
def perform
|
13
13
|
deliver
|
14
|
-
campaign.sent!
|
14
|
+
# campaign.sent!
|
15
15
|
end
|
16
16
|
|
17
17
|
def deliver
|
@@ -22,6 +22,7 @@ module Nuntius
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def new_message(subscriber, assigns = {})
|
25
|
+
assigns["campaign"] = context.campaign
|
25
26
|
assigns["subscriber"] = subscriber
|
26
27
|
if subscriber.nuntiable
|
27
28
|
name = Nuntius::BaseMessenger.liquid_variable_name_for(subscriber.nuntiable)
|
@@ -29,8 +30,11 @@ module Nuntius
|
|
29
30
|
end
|
30
31
|
message = Nuntius::Message.new(transport: campaign.transport, campaign: campaign, nuntiable: subscriber.nuntiable, metadata: campaign.metadata)
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
locale = nil
|
34
|
+
if subscriber.nuntiable
|
35
|
+
locale_proc = Nuntius::BaseMessenger.messenger_for_obj(subscriber.nuntiable).locale
|
36
|
+
locale = instance_exec(subscriber.nuntiable, &locale_proc) if locale_proc
|
37
|
+
end
|
34
38
|
|
35
39
|
message.from = render(:from, assigns, locale)
|
36
40
|
message.to = case campaign.transport
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nuntius
|
4
|
+
class CampaignMessagesTable < Nuntius::ApplicationTable
|
5
|
+
definition do
|
6
|
+
model Nuntius::Message
|
7
|
+
|
8
|
+
column(:to)
|
9
|
+
column(:status)
|
10
|
+
column(:created_at)
|
11
|
+
|
12
|
+
order created_at: :desc
|
13
|
+
|
14
|
+
link { |message| nuntius.admin_message_path(message) }
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def scope
|
20
|
+
@scope = Nuntius::Campaign.find_by(params[:campaign_id]).messages
|
21
|
+
@scope
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -27,21 +27,13 @@
|
|
27
27
|
.col-span-12
|
28
28
|
= f.input :subject
|
29
29
|
.col-span-12
|
30
|
-
= f.
|
31
|
-
|
30
|
+
= f.rich_text :html
|
31
|
+
.col-span-12
|
32
|
+
= f.input :metadata_yaml, as: :editor, mode: 'application/yaml', label: t('.metadata')
|
32
33
|
|
33
34
|
template data-toggle-target='toggleable' data-toggle-value='voice'
|
34
35
|
.col-span-12
|
35
36
|
= f.input :text, as: :editor, mode: 'text/plain'
|
36
37
|
- else
|
37
|
-
= sts.card :nuntius_admin_campaigns, title: @campaign.name, description: 'We are sending this campaign, you can no longer make any changes.', icon: 'fal fa-megaphone', content_padding: false do |card|
|
38
|
-
table.
|
39
|
-
thead
|
40
|
-
tr
|
41
|
-
th Status
|
42
|
-
th To
|
43
|
-
tbody
|
44
|
-
- for message in @messages
|
45
|
-
tr
|
46
|
-
td = link_to message.status, admin_message_path(message)
|
47
|
-
td = message.to
|
38
|
+
= sts.card :nuntius_admin_campaigns, title: @campaign.name, description: 'We are sending or have sent this campaign, you can no longer make any changes.', icon: 'fal fa-megaphone', content_padding: false do |card|
|
39
|
+
= sts.table :"nuntius/campaign_messages", params: { campaign_id: @campaign.id }
|
@@ -32,10 +32,11 @@
|
|
32
32
|
= (attachment.blob.byte_size / 1048576.0).round(2)
|
33
33
|
' MB
|
34
34
|
= link_to admin_layout_attachment_path(@layout, attachment.id), data: { controller: 'attachment-delete', 'action': 'attachment-delete#delete' } do
|
35
|
-
i.
|
35
|
+
i.fas.fa-xmark
|
36
36
|
=< link_to(main_app.rails_blob_path(attachment, disposition: 'attachment'),
|
37
37
|
title: attachment.filename)
|
38
|
-
i.
|
38
|
+
i.fas.fa-download
|
39
|
+
code.text-xs = sts.copyable main_app.rails_blob_url(attachment)
|
39
40
|
|
40
41
|
- if @layout.templates.exists?
|
41
42
|
- card.with_tab :templates, padding: false
|
@@ -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'
|
data/config/locales/en.yml
CHANGED
data/config/locales/nl.yml
CHANGED
@@ -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,15 +489,13 @@ 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
|
497
495
|
- app/services/nuntius/deliver_inbound_message_service.rb
|
498
496
|
- app/services/nuntius/retrieve_inbound_mail_service.rb
|
499
497
|
- app/tables/nuntius/application_table.rb
|
498
|
+
- app/tables/nuntius/campaign_messages_table.rb
|
500
499
|
- app/tables/nuntius/campaigns_table.rb
|
501
500
|
- app/tables/nuntius/layouts_table.rb
|
502
501
|
- app/tables/nuntius/lists_table.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
|