nuntius 1.0.27 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +77 -18
- data/Rakefile +16 -39
- data/app/controllers/nuntius/admin/campaigns_controller.rb +12 -10
- data/app/controllers/nuntius/admin/layouts/attachments_controller.rb +2 -1
- data/app/controllers/nuntius/admin/layouts_controller.rb +1 -1
- data/app/controllers/nuntius/admin/lists/subscribers_controller.rb +1 -1
- data/app/controllers/nuntius/admin/lists_controller.rb +4 -4
- data/app/controllers/nuntius/admin/locales_controller.rb +3 -2
- data/app/controllers/nuntius/admin/messages_controller.rb +2 -2
- data/app/controllers/nuntius/admin/templates_controller.rb +1 -1
- data/app/controllers/nuntius/api/events_controller.rb +2 -2
- data/app/controllers/nuntius/application_admin_controller.rb +1 -1
- data/app/controllers/nuntius/callbacks_controller.rb +4 -4
- data/app/controllers/nuntius/dashboard_controller.rb +1 -1
- data/app/controllers/nuntius/feedback_controller.rb +1 -2
- data/app/controllers/nuntius/inbound_messages/twilio_inbound_smses_controller.rb +7 -7
- data/app/controllers/nuntius/messages_controller.rb +1 -1
- data/app/controllers/nuntius/subscribers_controller.rb +33 -0
- data/app/drops/nuntius/list_drop.rb +7 -0
- data/app/drops/nuntius/subscriber_drop.rb +7 -0
- data/app/exceptions/nuntius/base_exception.rb +2 -0
- data/app/exceptions/nuntius/missing_messenger_exception.rb +2 -0
- data/app/helpers/nuntius/application_helper.rb +6 -11
- data/app/jobs/nuntius/deliver_inbound_message_job.rb +1 -1
- data/app/jobs/nuntius/purge_message_job.rb +2 -2
- data/app/jobs/nuntius/retrieve_mail_job.rb +2 -2
- data/app/jobs/nuntius/transport_delivery_job.rb +2 -2
- data/app/message_boxes/nuntius/base_message_box.rb +46 -23
- data/app/messengers/nuntius/base_messenger.rb +13 -12
- data/app/models/nuntius/application_record.rb +1 -1
- data/app/models/nuntius/attachment.rb +4 -2
- data/app/models/nuntius/campaign.rb +4 -51
- data/app/models/nuntius/concerns/yamlify.rb +2 -2
- data/app/models/nuntius/inbound_message.rb +2 -0
- data/app/models/nuntius/list.rb +11 -1
- data/app/models/nuntius/message.rb +34 -29
- data/app/models/nuntius/subscriber.rb +21 -1
- data/app/models/nuntius/template.rb +20 -20
- data/app/presenters/application_presenter.rb +1 -1
- data/app/presenters/template_presenter.rb +3 -3
- data/app/providers/nuntius/apnotic_push_provider.rb +17 -17
- data/app/providers/nuntius/base_provider.rb +6 -6
- data/app/providers/nuntius/firebase_push_provider.rb +8 -8
- data/app/providers/nuntius/houston_push_provider.rb +15 -15
- data/app/providers/nuntius/message_bird_sms_provider.rb +7 -7
- data/app/providers/nuntius/slack_slack_provider.rb +7 -7
- data/app/providers/nuntius/smtp_mail_provider.rb +36 -28
- data/app/providers/nuntius/teams_teams_provider.rb +24 -0
- data/app/providers/nuntius/twilio_sms_provider.rb +4 -4
- data/app/providers/nuntius/twilio_voice_provider.rb +13 -13
- data/app/services/nuntius/aws_sns_processor_service.rb +11 -11
- data/app/services/nuntius/deliver_campaign_service.rb +65 -0
- data/app/services/nuntius/deliver_inbound_message_service.rb +3 -2
- data/app/services/nuntius/retrieve_inbound_mail_service.rb +23 -16
- data/app/tables/nuntius_campaigns_table.rb +10 -1
- data/app/tables/nuntius_layouts_table.rb +4 -4
- data/app/tables/nuntius_lists_table.rb +1 -1
- data/app/tables/nuntius_locales_table.rb +1 -1
- data/app/tables/nuntius_messages_table.rb +5 -5
- data/app/tables/nuntius_subscribers_table.rb +3 -2
- data/app/tables/nuntius_templates_table.rb +12 -5
- data/app/transports/nuntius/base_transport.rb +1 -1
- data/app/transports/nuntius/mail_transport.rb +1 -1
- data/app/transports/nuntius/push_transport.rb +1 -1
- data/app/transports/nuntius/teams_transport.rb +6 -0
- data/app/views/nuntius/admin/campaigns/edit.html.slim +12 -16
- data/app/views/nuntius/admin/campaigns/index.html.slim +2 -2
- data/app/views/nuntius/admin/layouts/attachments/create.json.jbuilder +3 -3
- data/app/views/nuntius/admin/layouts/edit.html.slim +18 -19
- data/app/views/nuntius/admin/layouts/index.html.slim +2 -2
- data/app/views/nuntius/admin/lists/edit.html.slim +19 -9
- data/app/views/nuntius/admin/lists/index.html.slim +2 -2
- data/app/views/nuntius/admin/lists/subscribers/edit.html.slim +2 -2
- data/app/views/nuntius/admin/locales/edit.html.slim +3 -3
- data/app/views/nuntius/admin/locales/index.html.slim +2 -2
- data/app/views/nuntius/admin/messages/index.html.slim +2 -2
- data/app/views/nuntius/admin/messages/show.html.slim +12 -12
- data/app/views/nuntius/admin/templates/edit.html.slim +62 -64
- data/app/views/nuntius/admin/templates/index.html.slim +2 -2
- data/app/views/nuntius/dashboard/show.html.slim +2 -6
- data/app/views/nuntius/subscribers/show.html.slim +9 -0
- data/config/locales/en.yml +97 -1
- data/config/routes.rb +18 -8
- data/db/migrate/20190301201541_create_nuntius_templates.rb +5 -5
- data/db/migrate/20190301202436_create_nuntius_messages.rb +4 -4
- data/db/migrate/20190322114340_create_nuntius_campaigns.rb +2 -2
- data/db/migrate/20190322121338_create_nuntius_subscribers.rb +1 -1
- data/db/migrate/20190327124407_create_nuntius_layouts.rb +5 -5
- data/db/migrate/20190327143921_add_campaign_to_message.rb +1 -1
- data/db/migrate/20190417125153_change_message_status_default.rb +2 -2
- data/db/migrate/20190825080757_update_nuntius_message_sending_to_sent.rb +2 -2
- data/db/migrate/20200220154927_change_nuntius_templates_payload_type.rb +1 -1
- data/db/migrate/20200318095339_create_nuntius_attachments.rb +2 -2
- data/db/migrate/20201121185718_create_nuntius_inbound_messages.rb +1 -1
- data/db/migrate/20240205204719_add_description_to_list.rb +5 -0
- data/db/migrate/20240206203019_add_slug_to_nuntius_list.rb +9 -0
- data/lib/nuntius/active_record_helpers.rb +4 -4
- data/lib/nuntius/configuration.rb +64 -27
- data/lib/nuntius/deprecator.rb +2 -0
- data/lib/nuntius/devise.rb +1 -1
- data/lib/nuntius/engine.rb +13 -27
- data/lib/nuntius/i18n_store.rb +6 -5
- data/lib/nuntius/liquid/tags/attach_tag.rb +11 -11
- data/lib/nuntius/mail_allow_list.rb +2 -2
- data/lib/nuntius/nuntiable.rb +3 -1
- data/lib/nuntius/transactio.rb +1 -1
- data/lib/nuntius/version.rb +1 -1
- data/lib/nuntius.rb +13 -27
- data/lib/preamble.rb +18 -18
- data/lib/tasks/nuntius_tasks.rake +4 -4
- metadata +48 -33
- data/app/jobs/nuntius/process_inbound_message_job.rb +0 -10
- data/app/reportlets/nuntius/application_reportlet.rb +0 -35
- data/app/reportlets/nuntius/daily_messages_per_template_reportlet.rb +0 -50
- data/config/webpack/development.js +0 -5
- data/config/webpack/environment.js +0 -4
- data/config/webpack/production.js +0 -5
- data/config/webpack/test.js +0 -5
- data/config/webpacker.yml +0 -119
data/config/locales/en.yml
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
en:
|
2
1
|
nuntius:
|
3
2
|
flash:
|
4
3
|
error: There were problems saving the %{model}
|
@@ -11,6 +10,103 @@ en:
|
|
11
10
|
resend:
|
12
11
|
resend_success: Resent message
|
13
12
|
resend_error: Failed to resend message
|
13
|
+
index:
|
14
|
+
card:
|
15
|
+
nuntius_admin_messages:
|
16
|
+
title: Messages
|
17
|
+
tab:
|
18
|
+
Nuntius messages: Messages
|
19
|
+
show:
|
20
|
+
message: Message
|
21
|
+
card:
|
22
|
+
nuntius_admin_messages:
|
23
|
+
tab:
|
24
|
+
preview: Preview
|
25
|
+
details: Details
|
26
|
+
info_item:
|
27
|
+
main:
|
28
|
+
status: Status
|
29
|
+
transport: Transport
|
30
|
+
provider: Provider
|
31
|
+
provider_id: Provider ID
|
32
|
+
request_id: Request ID
|
33
|
+
refreshes: Refreshes
|
34
|
+
last_sent_at: Last Sent At
|
35
|
+
created_at: Created At
|
36
|
+
templates:
|
37
|
+
index:
|
38
|
+
card:
|
39
|
+
nuntius_admin_templates:
|
40
|
+
title: Templates
|
41
|
+
tab:
|
42
|
+
Nuntius templates: Templates
|
43
|
+
edit:
|
44
|
+
card:
|
45
|
+
nuntius_admin_templates:
|
46
|
+
title: Templates
|
47
|
+
tab:
|
48
|
+
edit: Edit
|
49
|
+
nuntius_messages: Messages
|
50
|
+
metadata: Metadata
|
51
|
+
layouts:
|
52
|
+
index:
|
53
|
+
card:
|
54
|
+
nuntius_admin_layouts:
|
55
|
+
title: Layouts
|
56
|
+
tab:
|
57
|
+
Nuntius layouts: Layouts
|
58
|
+
edit:
|
59
|
+
card:
|
60
|
+
nuntius_admin_layouts:
|
61
|
+
title: Layouts
|
62
|
+
tab:
|
63
|
+
edit: Edit
|
64
|
+
metadata: Metadata
|
65
|
+
media: Media
|
66
|
+
metadata: Metadata
|
67
|
+
locales:
|
68
|
+
index:
|
69
|
+
card:
|
70
|
+
nuntius_admin_locales:
|
71
|
+
title: Locales
|
72
|
+
tab:
|
73
|
+
Nuntius locales: Locales
|
74
|
+
edit:
|
75
|
+
card:
|
76
|
+
nuntius_admin_locales:
|
77
|
+
title: Locales
|
78
|
+
data: Data
|
79
|
+
metadata: Metadata
|
80
|
+
campaigns:
|
81
|
+
index:
|
82
|
+
card:
|
83
|
+
nuntius_admin_campaigns:
|
84
|
+
title: Campaigns
|
85
|
+
tab:
|
86
|
+
Nuntius campaigns: Campaigns
|
87
|
+
edit:
|
88
|
+
card:
|
89
|
+
nuntius_admin_campaigns:
|
90
|
+
title: Campaigns
|
91
|
+
lists:
|
92
|
+
subscribers:
|
93
|
+
edit:
|
94
|
+
subscribers: Subscribers
|
95
|
+
index:
|
96
|
+
card:
|
97
|
+
nuntius_admin_lists:
|
98
|
+
title: Lists
|
99
|
+
tab:
|
100
|
+
Nuntius lists: Lists
|
101
|
+
edit:
|
102
|
+
description: List description
|
103
|
+
description_hint: Describe the list in detail for the subscibers, explain if they can unsubscribe, how often they will receive messages, etc.
|
104
|
+
card:
|
105
|
+
nuntius_admin_lists:
|
106
|
+
title: Lists
|
107
|
+
tab:
|
108
|
+
edit: Edit
|
109
|
+
nuntius_subscribers: Subscribers
|
14
110
|
breadcrumbs:
|
15
111
|
nuntius: Nuntius
|
16
112
|
dashboard: Dashboard
|
data/config/routes.rb
CHANGED
@@ -5,34 +5,44 @@ Nuntius::Engine.routes.draw do
|
|
5
5
|
resource :twilio_inbound_smses
|
6
6
|
end
|
7
7
|
|
8
|
-
get
|
9
|
-
post
|
8
|
+
get "callbacks/:message_id(/*path)", to: "callbacks#create", as: :callback
|
9
|
+
post "callbacks/:message_id(/*path)", to: "callbacks#create"
|
10
10
|
|
11
|
-
post
|
11
|
+
post "feedback/awssns" => "feedback#awssns"
|
12
12
|
|
13
13
|
resources :messages
|
14
14
|
resources :campaigns
|
15
|
+
resources :subscribers do
|
16
|
+
member do
|
17
|
+
post :unsubscribe
|
18
|
+
post :subscribe
|
19
|
+
end
|
20
|
+
end
|
15
21
|
|
16
22
|
namespace :api do
|
17
23
|
resources :events
|
18
24
|
end
|
19
25
|
|
20
26
|
namespace :admin do
|
21
|
-
resources :campaigns
|
27
|
+
resources :campaigns do
|
28
|
+
member do
|
29
|
+
post "publish", action: "publish"
|
30
|
+
end
|
31
|
+
end
|
22
32
|
resources :layouts do
|
23
|
-
resources :attachments, controller:
|
33
|
+
resources :attachments, controller: "layouts/attachments"
|
24
34
|
end
|
25
35
|
resources :lists do
|
26
|
-
resources :subscribers, controller:
|
36
|
+
resources :subscribers, controller: "lists/subscribers"
|
27
37
|
end
|
28
38
|
resources :messages do
|
29
39
|
member do
|
30
|
-
post
|
40
|
+
post "resend", action: "resend"
|
31
41
|
end
|
32
42
|
end
|
33
43
|
resources :layouts
|
34
44
|
resources :locales
|
35
45
|
resources :templates
|
36
46
|
end
|
37
|
-
root to:
|
47
|
+
root to: "dashboard#show"
|
38
48
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
class CreateNuntiusTemplates < ActiveRecord::Migration[5.1]
|
4
4
|
def change
|
5
|
-
enable_extension
|
5
|
+
enable_extension "pgcrypto"
|
6
6
|
|
7
7
|
create_table :nuntius_templates, id: :uuid do |t|
|
8
8
|
t.string :klass
|
@@ -12,14 +12,14 @@ class CreateNuntiusTemplates < ActiveRecord::Migration[5.1]
|
|
12
12
|
t.string :description
|
13
13
|
t.jsonb :metadata, null: false, default: {}
|
14
14
|
|
15
|
-
t.references :layout, index: true, type: :uuid, foreign_key: {
|
15
|
+
t.references :layout, index: true, type: :uuid, foreign_key: {to_table: :nuntius_templates}
|
16
16
|
|
17
17
|
t.string :from
|
18
18
|
t.string :to
|
19
19
|
t.string :subject
|
20
|
-
t.text
|
21
|
-
t.text
|
22
|
-
t.jsonb
|
20
|
+
t.text :html
|
21
|
+
t.text :text
|
22
|
+
t.jsonb :payload
|
23
23
|
|
24
24
|
t.timestamps
|
25
25
|
end
|
@@ -2,16 +2,16 @@
|
|
2
2
|
|
3
3
|
class CreateNuntiusMessages < ActiveRecord::Migration[5.1]
|
4
4
|
def change
|
5
|
-
enable_extension
|
5
|
+
enable_extension "uuid-ossp"
|
6
6
|
|
7
7
|
create_table :nuntius_messages, id: :uuid do |t|
|
8
|
-
t.references :template, index: true, type: :uuid, foreign_key: {
|
9
|
-
t.references :parent_message, index: true, type: :uuid, foreign_key: {
|
8
|
+
t.references :template, index: true, type: :uuid, foreign_key: {to_table: :nuntius_templates}
|
9
|
+
t.references :parent_message, index: true, type: :uuid, foreign_key: {to_table: :nuntius_messages}
|
10
10
|
t.references :nuntiable, polymorphic: true, index: true, type: :uuid
|
11
11
|
|
12
12
|
t.integer :refreshes, default: 0
|
13
13
|
|
14
|
-
t.string :status, default:
|
14
|
+
t.string :status, default: "draft"
|
15
15
|
t.string :transport
|
16
16
|
t.string :provider
|
17
17
|
t.string :provider_id
|
@@ -4,8 +4,8 @@ class CreateNuntiusCampaigns < ActiveRecord::Migration[5.2]
|
|
4
4
|
def change
|
5
5
|
create_table :nuntius_campaigns, id: :uuid do |t|
|
6
6
|
t.string :name
|
7
|
-
t.string :transport, default:
|
8
|
-
t.references :list, index: true, type: :uuid, foreign_key: {
|
7
|
+
t.string :transport, default: "mail"
|
8
|
+
t.references :list, index: true, type: :uuid, foreign_key: {to_table: :nuntius_lists}
|
9
9
|
|
10
10
|
t.string :from
|
11
11
|
t.string :subject
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class CreateNuntiusSubscribers < ActiveRecord::Migration[5.2]
|
4
4
|
def change
|
5
5
|
create_table :nuntius_subscribers, id: :uuid do |t|
|
6
|
-
t.references :list, index: true, type: :uuid, foreign_key: {
|
6
|
+
t.references :list, index: true, type: :uuid, foreign_key: {to_table: :nuntius_lists}
|
7
7
|
|
8
8
|
t.string :first_name
|
9
9
|
t.string :last_name
|
@@ -11,14 +11,14 @@ class CreateNuntiusLayouts < ActiveRecord::Migration[5.2]
|
|
11
11
|
t.timestamps
|
12
12
|
end
|
13
13
|
|
14
|
-
remove_reference :nuntius_templates, :layout, index: true, type: :uuid, foreign_key: {
|
15
|
-
add_reference :nuntius_templates, :layout, index: true, type: :uuid, foreign_key: {
|
16
|
-
add_reference :nuntius_campaigns, :layout, index: true, type: :uuid, foreign_key: {
|
14
|
+
remove_reference :nuntius_templates, :layout, index: true, type: :uuid, foreign_key: {to_table: :nuntius_templates}
|
15
|
+
add_reference :nuntius_templates, :layout, index: true, type: :uuid, foreign_key: {to_table: :nuntius_layouts}
|
16
|
+
add_reference :nuntius_campaigns, :layout, index: true, type: :uuid, foreign_key: {to_table: :nuntius_layouts}
|
17
17
|
end
|
18
18
|
|
19
19
|
def down
|
20
20
|
drop_table :nuntius_layouts
|
21
|
-
remove_reference :nuntius_templates, :layout, index: true, type: :uuid, foreign_key: {
|
22
|
-
add_reference :nuntius_templates, :layout, index: true, type: :uuid, foreign_key: {
|
21
|
+
remove_reference :nuntius_templates, :layout, index: true, type: :uuid, foreign_key: {to_table: :nuntius_layouts}
|
22
|
+
add_reference :nuntius_templates, :layout, index: true, type: :uuid, foreign_key: {to_table: :nuntius_templates}
|
23
23
|
end
|
24
24
|
end
|
@@ -2,6 +2,6 @@
|
|
2
2
|
|
3
3
|
class AddCampaignToMessage < ActiveRecord::Migration[5.2]
|
4
4
|
def change
|
5
|
-
add_reference :nuntius_messages, :campaign, type: :uuid, foreign_key: {
|
5
|
+
add_reference :nuntius_messages, :campaign, type: :uuid, foreign_key: {to_table: :nuntius_campaigns}
|
6
6
|
end
|
7
7
|
end
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
class ChangeMessageStatusDefault < ActiveRecord::Migration[5.2]
|
4
4
|
def change
|
5
|
-
change_column_default(:nuntius_messages, :status, from:
|
5
|
+
change_column_default(:nuntius_messages, :status, from: "draft", to: "pending")
|
6
6
|
|
7
|
-
Nuntius::Message.where(status:
|
7
|
+
Nuntius::Message.where(status: "draft").update(status: "pending")
|
8
8
|
end
|
9
9
|
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
class UpdateNuntiusMessageSendingToSent < ActiveRecord::Migration[5.2]
|
4
4
|
def up
|
5
|
-
Nuntius::Message.where(status:
|
5
|
+
Nuntius::Message.where(status: "sending").update_all(status: "sent")
|
6
6
|
end
|
7
7
|
|
8
8
|
def down
|
9
|
-
Nuntius::Message.where(status:
|
9
|
+
Nuntius::Message.where(status: "sent").update_all(status: "sending")
|
10
10
|
end
|
11
11
|
end
|
@@ -2,6 +2,6 @@
|
|
2
2
|
|
3
3
|
class ChangeNuntiusTemplatesPayloadType < ActiveRecord::Migration[5.2]
|
4
4
|
def change
|
5
|
-
execute
|
5
|
+
execute "ALTER TABLE nuntius_templates ALTER COLUMN payload TYPE TEXT USING payload::text;"
|
6
6
|
end
|
7
7
|
end
|
@@ -5,8 +5,8 @@ class CreateNuntiusAttachments < ActiveRecord::Migration[5.2]
|
|
5
5
|
end
|
6
6
|
|
7
7
|
create_table :nuntius_attachments_messages, id: false do |t|
|
8
|
-
t.belongs_to :message, type: :uuid, foreign_key: {
|
9
|
-
t.belongs_to :attachment, type: :uuid, foreign_key: {
|
8
|
+
t.belongs_to :message, type: :uuid, foreign_key: {to_table: :nuntius_messages}
|
9
|
+
t.belongs_to :attachment, type: :uuid, foreign_key: {to_table: :nuntius_attachments}
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class CreateNuntiusInboundMessages < ActiveRecord::Migration[6.0]
|
2
2
|
def change
|
3
3
|
create_table :nuntius_inbound_messages, id: :uuid do |t|
|
4
|
-
t.string :status, default:
|
4
|
+
t.string :status, default: "pending"
|
5
5
|
t.string :transport
|
6
6
|
t.string :provider
|
7
7
|
t.string :provider_id
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class AddSlugToNuntiusList < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
add_column :nuntius_lists, :slug, :string
|
4
|
+
add_index :nuntius_lists, :slug, unique: true
|
5
|
+
add_column :nuntius_lists, :allow_unsubscribe, :boolean, default: true, null: false
|
6
|
+
|
7
|
+
add_column :nuntius_subscribers, :unsubscribed_at, :timestamp
|
8
|
+
end
|
9
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
3
|
+
require_relative "nuntiable"
|
4
|
+
require_relative "devise"
|
5
|
+
require_relative "state_machine"
|
6
|
+
require_relative "transactio"
|
7
7
|
|
8
8
|
module Nuntius::ActiveRecordHelpers
|
9
9
|
extend ActiveSupport::Concern
|
@@ -1,40 +1,60 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Nuntius
|
4
|
+
module Options
|
5
|
+
module ClassMethods
|
6
|
+
def option(name, default: nil)
|
7
|
+
attr_accessor(name)
|
8
|
+
schema[name] = default
|
9
|
+
end
|
10
|
+
|
11
|
+
def schema
|
12
|
+
@schema ||= {}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def set_defaults!
|
17
|
+
self.class.schema.each do |name, default|
|
18
|
+
instance_variable_set(:"@#{name}", default)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.included(cls)
|
23
|
+
cls.extend(ClassMethods)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
4
27
|
class Configuration
|
5
|
-
|
6
|
-
|
28
|
+
include Options
|
29
|
+
|
30
|
+
option :logger, default: -> { Rails.logger }
|
31
|
+
option :admin_authentication_module, default: "Auxilium::Concerns::AdminAuthenticated"
|
32
|
+
option :base_controller, default: "::ApplicationController"
|
33
|
+
option :base_runner, default: "Nuntius::BasicApplicationRunner"
|
34
|
+
option :layout, default: "application"
|
35
|
+
option :admin_layout, default: "application"
|
36
|
+
option :jobs_queue_name, default: "message"
|
37
|
+
option :allow_custom_events, default: false
|
38
|
+
option :active_storage_service
|
39
|
+
option :host, default: ->(message) {}
|
40
|
+
|
41
|
+
attr_accessor :visible_scope, :add_metadata, :metadata_fields, :default_template_scope
|
42
|
+
attr_writer :metadata_humanize, :default_params, :flow_color
|
7
43
|
|
8
44
|
attr_reader :transports, :providers
|
9
45
|
|
10
46
|
def initialize
|
11
|
-
|
12
|
-
|
13
|
-
@base_controller = '::ApplicationController'
|
14
|
-
@base_runner = 'Nuntius::BasicApplicationRunner'
|
47
|
+
set_defaults!
|
48
|
+
|
15
49
|
@nuntiable_classes = []
|
16
50
|
@nuntiable_class_names = []
|
17
51
|
@transports = []
|
18
52
|
@providers = {}
|
19
|
-
@jobs_queue_name = :message
|
20
53
|
@visible_scope = -> { all }
|
21
54
|
@add_metadata = -> {}
|
22
55
|
@metadata_fields = {}
|
23
56
|
@metadata_humanize = ->(data) { data.inspect }
|
24
57
|
@default_template_scope = ->(_object) { all }
|
25
|
-
@allow_custom_events = false
|
26
|
-
@layout = 'application'
|
27
|
-
@admin_layout = 'application'
|
28
|
-
@active_storage_service = nil
|
29
|
-
end
|
30
|
-
|
31
|
-
# logger [Object].
|
32
|
-
def logger
|
33
|
-
@logger.is_a?(Proc) ? instance_exec(&@logger) : @logger
|
34
|
-
end
|
35
|
-
|
36
|
-
def host(message)
|
37
|
-
@host.is_a?(Proc) ? instance_exec(message, &@host) : @host
|
38
58
|
end
|
39
59
|
|
40
60
|
# Make the part that is important for visible readable for humans
|
@@ -42,11 +62,6 @@ module Nuntius
|
|
42
62
|
@metadata_humanize.is_a?(Proc) ? instance_exec(metadata, &@metadata_humanize) : @metadata_humanize
|
43
63
|
end
|
44
64
|
|
45
|
-
# admin_mount_point [String].
|
46
|
-
def admin_mount_point
|
47
|
-
@admin_mount_point ||= '/nuntius'
|
48
|
-
end
|
49
|
-
|
50
65
|
def add_nuntiable_class(klass)
|
51
66
|
@nuntiable_class_names = []
|
52
67
|
@nuntiable_classes << klass.to_s unless @nuntiable_classes.include?(klass.to_s)
|
@@ -63,7 +78,7 @@ module Nuntius
|
|
63
78
|
@providers[transport.to_sym] ||= []
|
64
79
|
@providers[transport.to_sym].push(provider: provider, priority: priority, timeout: timeout, settings: settings)
|
65
80
|
else
|
66
|
-
Nuntius.logger.warn "provider #{provider} not enabled as transport #{transport} is not enabled"
|
81
|
+
Nuntius.config.logger.call.warn "provider #{provider} not enabled as transport #{transport} is not enabled"
|
67
82
|
end
|
68
83
|
end
|
69
84
|
|
@@ -75,11 +90,15 @@ module Nuntius
|
|
75
90
|
@default_params.is_a?(Proc) ? instance_exec(transaction_log_entry, &@default_params) : @default_params
|
76
91
|
end
|
77
92
|
|
93
|
+
def flow_color(template_id)
|
94
|
+
@flow_color.is_a?(Proc) ? instance_exec(template_id, &@flow_color) : @flow_color
|
95
|
+
end
|
96
|
+
|
78
97
|
private
|
79
98
|
|
80
99
|
def compile_nuntiable_class_names
|
81
100
|
names = []
|
82
|
-
names <<
|
101
|
+
names << "Custom" if allow_custom_events
|
83
102
|
|
84
103
|
@nuntiable_classes.each do |klass_name|
|
85
104
|
klass = klass_name.constantize
|
@@ -94,4 +113,22 @@ module Nuntius
|
|
94
113
|
@nuntiable_class_names = compile_nuntiable_class_names
|
95
114
|
end
|
96
115
|
end
|
116
|
+
|
117
|
+
module Configurable
|
118
|
+
attr_writer :config
|
119
|
+
|
120
|
+
def config
|
121
|
+
@config ||= Configuration.new
|
122
|
+
end
|
123
|
+
|
124
|
+
def configure
|
125
|
+
yield(config)
|
126
|
+
end
|
127
|
+
|
128
|
+
alias_method :setup, :configure
|
129
|
+
|
130
|
+
def reset_config!
|
131
|
+
@config = Configuration.new
|
132
|
+
end
|
133
|
+
end
|
97
134
|
end
|
data/lib/nuntius/deprecator.rb
CHANGED
data/lib/nuntius/devise.rb
CHANGED
@@ -12,7 +12,7 @@ module Nuntius
|
|
12
12
|
|
13
13
|
orchestrator.override_devise_notification do |notification, *devise_params|
|
14
14
|
# All notifications have either a token as the first param, or nothing
|
15
|
-
Nuntius.event(notification, self, {
|
15
|
+
Nuntius.event(notification, self, {token: devise_params.first})
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/lib/nuntius/engine.rb
CHANGED
@@ -1,46 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "auxilium"
|
4
|
+
require "evento"
|
5
|
+
require "inky"
|
6
|
+
require "faraday"
|
7
|
+
require "faraday/follow_redirects"
|
8
|
+
require "liquidum"
|
9
|
+
require "premailer"
|
10
|
+
require "state_machines-activerecord"
|
11
|
+
require "servitium"
|
12
|
+
|
3
13
|
module Nuntius
|
4
14
|
class Engine < ::Rails::Engine
|
5
15
|
isolate_namespace Nuntius
|
6
16
|
|
7
|
-
initializer
|
8
|
-
path = File.expand_path(File.join(File.dirname(__FILE__),
|
17
|
+
initializer "nuntius.config" do |_app|
|
18
|
+
path = File.expand_path(File.join(File.dirname(__FILE__), ".", "liquid", "{tags,filters}", "*.rb"))
|
9
19
|
Dir.glob(path).each do |c|
|
10
20
|
require_dependency(c)
|
11
21
|
end
|
12
22
|
end
|
13
23
|
|
14
|
-
initializer
|
15
|
-
unless app.root.to_s.match? root.to_s
|
16
|
-
config.paths['db/migrate'].expanded.each do |expanded_path|
|
17
|
-
app.config.paths['db/migrate'] << expanded_path
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
initializer 'active_storage.attached' do
|
24
|
+
initializer "active_storage.attached" do
|
23
25
|
config.after_initialize do
|
24
26
|
ActiveSupport.on_load(:active_record) do
|
25
27
|
Nuntius::Attachment.include(Nuntius::ActiveStorageHelpers)
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
29
|
-
|
30
|
-
#
|
31
|
-
# initializer "webpacker.proxy" do |app|
|
32
|
-
# insert_middleware = begin
|
33
|
-
# Nuntius.webpacker.config.dev_server.present?
|
34
|
-
# rescue
|
35
|
-
# nil
|
36
|
-
# end
|
37
|
-
# next unless insert_middleware
|
38
|
-
#
|
39
|
-
# app.middleware.insert_before(
|
40
|
-
# 0, Webpacker::DevServerProxy, # "Webpacker::DevServerProxy" if Rails version < 5
|
41
|
-
# ssl_verify_none: true,
|
42
|
-
# webpacker: Nuntius.webpacker
|
43
|
-
# )
|
44
|
-
# end
|
45
31
|
end
|
46
32
|
end
|
data/lib/nuntius/i18n_store.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "i18n/core_ext/hash"
|
4
4
|
|
5
5
|
module Nuntius
|
6
6
|
begin
|
7
|
-
require
|
7
|
+
require "oj"
|
8
8
|
class JSON
|
9
9
|
class << self
|
10
10
|
def encode(value)
|
@@ -17,12 +17,13 @@ module Nuntius
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
rescue LoadError
|
20
|
-
require
|
20
|
+
require "active_support/json"
|
21
21
|
JSON = ActiveSupport::JSON
|
22
22
|
end
|
23
23
|
|
24
24
|
class I18nStore
|
25
|
-
def initialize
|
25
|
+
def initialize
|
26
|
+
end
|
26
27
|
|
27
28
|
def keys
|
28
29
|
return [] unless template
|
@@ -82,7 +83,7 @@ module Nuntius
|
|
82
83
|
|
83
84
|
def flat_hash(hash = {})
|
84
85
|
(hash || {}).reduce({}) do |a, (k, v)|
|
85
|
-
tmp = v.is_a?(Hash) ? flat_hash(v).
|
86
|
+
tmp = v.is_a?(Hash) ? flat_hash(v).transform_keys { |k2| "#{k}.#{k2}" } : {k => v}
|
86
87
|
a.merge(tmp)
|
87
88
|
end
|
88
89
|
end
|
@@ -11,10 +11,10 @@ class AttachTag < LiquidumTag
|
|
11
11
|
|
12
12
|
return unless argv1
|
13
13
|
|
14
|
-
message = context.registers[
|
14
|
+
message = context.registers["message"]
|
15
15
|
|
16
16
|
if argv1.is_a? String
|
17
|
-
message.add_attachment({
|
17
|
+
message.add_attachment({url: argv1})
|
18
18
|
elsif argv1.instance_of?(ActiveStorageAttachedOneDrop) || argv1.instance_of?(ActiveStorage::AttachmentDrop)
|
19
19
|
|
20
20
|
io = StringIO.new(argv1.download)
|
@@ -22,23 +22,23 @@ class AttachTag < LiquidumTag
|
|
22
22
|
content_type = argv1.content_type
|
23
23
|
filename = argv1.filename
|
24
24
|
|
25
|
-
if arg(:convert) ==
|
26
|
-
content_type =
|
25
|
+
if arg(:convert) == "pdf" && content_type != "application/pdf"
|
26
|
+
content_type = "application/pdf"
|
27
27
|
pdf = Labelary::Label.render(zpl: io.read,
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
content_type: content_type,
|
29
|
+
dpmm: 8,
|
30
|
+
width: arg(:width).blank? ? 4 : arg(:width),
|
31
|
+
height: arg(:height).blank? ? 6 : arg(:height))
|
32
32
|
|
33
33
|
io = StringIO.new(pdf)
|
34
34
|
filename = "#{filename}.pdf"
|
35
35
|
end
|
36
36
|
|
37
|
-
message.add_attachment({
|
37
|
+
message.add_attachment({content: io, filename: filename, content_type: content_type})
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
""
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
Liquid::Template.register_tag(
|
44
|
+
Liquid::Template.register_tag("attach", AttachTag)
|