nuntius 0.1.1 → 1.0.27

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +199 -63
  4. data/Rakefile +62 -1
  5. data/app/controllers/nuntius/admin/campaigns_controller.rb +56 -0
  6. data/app/controllers/nuntius/admin/layouts/attachments_controller.rb +32 -0
  7. data/app/controllers/nuntius/admin/layouts_controller.rb +50 -0
  8. data/app/controllers/nuntius/admin/lists/subscribers_controller.rb +50 -0
  9. data/app/controllers/nuntius/admin/lists_controller.rb +46 -0
  10. data/app/controllers/nuntius/admin/locales_controller.rb +46 -0
  11. data/app/controllers/nuntius/admin/messages_controller.rb +24 -0
  12. data/app/controllers/nuntius/admin/templates_controller.rb +56 -0
  13. data/app/controllers/nuntius/api/events_controller.rb +16 -0
  14. data/app/controllers/nuntius/application_admin_controller.rb +11 -0
  15. data/app/controllers/nuntius/application_controller.rb +12 -0
  16. data/app/controllers/nuntius/callbacks_controller.rb +21 -0
  17. data/app/controllers/nuntius/dashboard_controller.rb +12 -0
  18. data/app/controllers/nuntius/feedback_controller.rb +17 -0
  19. data/app/controllers/nuntius/inbound_messages/twilio_inbound_smses_controller.rb +56 -0
  20. data/app/controllers/nuntius/messages_controller.rb +13 -0
  21. data/app/drops/nuntius/application_drop.rb +17 -0
  22. data/app/drops/nuntius/campaign_drop.rb +7 -0
  23. data/app/drops/nuntius/layout_drop.rb +11 -0
  24. data/app/drops/nuntius/message_drop.rb +11 -0
  25. data/app/drops/nuntius/template_drop.rb +7 -0
  26. data/app/exceptions/nuntius/base_exception.rb +4 -0
  27. data/app/exceptions/nuntius/missing_messenger_exception.rb +4 -0
  28. data/app/helpers/nuntius/application_helper.rb +78 -0
  29. data/app/jobs/nuntius/application_job.rb +9 -0
  30. data/app/jobs/nuntius/deliver_inbound_message_job.rb +10 -0
  31. data/app/jobs/nuntius/messenger_job.rb +17 -0
  32. data/app/jobs/nuntius/process_inbound_message_job.rb +10 -0
  33. data/app/jobs/nuntius/purge_message_job.rb +13 -0
  34. data/app/jobs/nuntius/retrieve_mail_job.rb +18 -0
  35. data/app/jobs/nuntius/transport_delivery_job.rb +32 -0
  36. data/app/jobs/nuntius/transport_refresh_job.rb +22 -0
  37. data/app/message_boxes/nuntius/base_message_box.rb +75 -0
  38. data/app/messengers/nuntius/base_messenger.rb +193 -0
  39. data/app/messengers/nuntius/custom_messenger.rb +6 -0
  40. data/app/models/nuntius/application_record.rb +11 -0
  41. data/app/models/nuntius/attachment.rb +13 -0
  42. data/app/models/nuntius/campaign.rb +75 -0
  43. data/app/models/nuntius/concerns/metadata_scoped.rb +31 -0
  44. data/app/models/nuntius/concerns/yamlify.rb +23 -0
  45. data/app/models/nuntius/inbound_message.rb +14 -0
  46. data/app/models/nuntius/layout.rb +13 -0
  47. data/app/models/nuntius/list.rb +10 -0
  48. data/app/models/nuntius/locale.rb +11 -0
  49. data/app/models/nuntius/message.rb +148 -0
  50. data/app/models/nuntius/subscriber.rb +12 -0
  51. data/app/models/nuntius/template.rb +102 -0
  52. data/app/presenters/application_presenter.rb +28 -0
  53. data/app/presenters/template_presenter.rb +17 -0
  54. data/app/providers/nuntius/apnotic_push_provider.rb +44 -0
  55. data/app/providers/nuntius/base_provider.rb +72 -0
  56. data/app/providers/nuntius/firebase_push_provider.rb +26 -0
  57. data/app/providers/nuntius/houston_push_provider.rb +40 -0
  58. data/app/providers/nuntius/message_bird_sms_provider.rb +39 -0
  59. data/app/providers/nuntius/slack_slack_provider.rb +36 -0
  60. data/app/providers/nuntius/smtp_mail_provider.rb +80 -0
  61. data/app/providers/nuntius/twilio_sms_provider.rb +37 -0
  62. data/app/providers/nuntius/twilio_voice_provider.rb +70 -0
  63. data/app/reportlets/nuntius/application_reportlet.rb +35 -0
  64. data/app/reportlets/nuntius/daily_messages_per_template_reportlet.rb +50 -0
  65. data/app/runners/nuntius/application_runner.rb +6 -0
  66. data/app/runners/nuntius/basic_application_runner.rb +15 -0
  67. data/app/runners/nuntius/timebased_events_runner.rb +15 -0
  68. data/app/services/nuntius/application_service.rb +7 -0
  69. data/app/services/nuntius/aws_sns_processor_service.rb +81 -0
  70. data/app/services/nuntius/deliver_inbound_message_service.rb +14 -0
  71. data/app/services/nuntius/retrieve_inbound_mail_service.rb +36 -0
  72. data/app/tables/nuntius_campaigns_table.rb +21 -0
  73. data/app/tables/nuntius_layouts_table.rb +24 -0
  74. data/app/tables/nuntius_lists_table.rb +19 -0
  75. data/app/tables/nuntius_locales_table.rb +18 -0
  76. data/app/tables/nuntius_messages_table.rb +36 -0
  77. data/app/tables/nuntius_subscribers_table.rb +19 -0
  78. data/app/tables/nuntius_templates_table.rb +30 -0
  79. data/app/transports/nuntius/base_transport.rb +36 -0
  80. data/app/transports/nuntius/mail_transport.rb +35 -0
  81. data/app/transports/nuntius/push_transport.rb +15 -0
  82. data/app/transports/nuntius/slack_transport.rb +6 -0
  83. data/app/transports/nuntius/sms_transport.rb +6 -0
  84. data/app/transports/nuntius/voice_transport.rb +6 -0
  85. data/app/validators/liquid_validator.rb +11 -0
  86. data/app/views/nuntius/admin/campaigns/edit.html.slim +49 -0
  87. data/app/views/nuntius/admin/campaigns/index.html.slim +2 -0
  88. data/app/views/nuntius/admin/layouts/attachments/_attachments.html.slim +28 -0
  89. data/app/views/nuntius/admin/layouts/attachments/_index.html.slim +2 -0
  90. data/app/views/nuntius/admin/layouts/attachments/create.json.jbuilder +5 -0
  91. data/app/views/nuntius/admin/layouts/edit.html.slim +24 -0
  92. data/app/views/nuntius/admin/layouts/index.html.slim +2 -0
  93. data/app/views/nuntius/admin/lists/edit.html.slim +14 -0
  94. data/app/views/nuntius/admin/lists/index.html.slim +2 -0
  95. data/app/views/nuntius/admin/lists/subscribers/edit.html.slim +14 -0
  96. data/app/views/nuntius/admin/locales/edit.html.slim +14 -0
  97. data/app/views/nuntius/admin/locales/index.html.slim +2 -0
  98. data/app/views/nuntius/admin/messages/index.html.slim +2 -0
  99. data/app/views/nuntius/admin/messages/show.html.slim +56 -0
  100. data/app/views/nuntius/admin/templates/edit.html.slim +81 -0
  101. data/app/views/nuntius/admin/templates/index.html.slim +2 -0
  102. data/app/views/nuntius/dashboard/show.html.slim +7 -0
  103. data/app/views/nuntius/messages/show.html.slim +7 -0
  104. data/config/locales/en.yml +22 -0
  105. data/config/locales/nl.yml +22 -0
  106. data/config/routes.rb +38 -0
  107. data/config/webpack/development.js +5 -0
  108. data/config/webpack/environment.js +4 -0
  109. data/config/webpack/production.js +5 -0
  110. data/config/webpack/test.js +5 -0
  111. data/config/webpacker.yml +119 -0
  112. data/db/migrate/20190301201541_create_nuntius_templates.rb +27 -0
  113. data/db/migrate/20190301202436_create_nuntius_messages.rb +30 -0
  114. data/db/migrate/20190322112815_create_nuntius_lists.rb +12 -0
  115. data/db/migrate/20190322114340_create_nuntius_campaigns.rb +18 -0
  116. data/db/migrate/20190322121338_create_nuntius_subscribers.rb +17 -0
  117. data/db/migrate/20190327123535_add_metadata_to_models.rb +8 -0
  118. data/db/migrate/20190327124407_create_nuntius_layouts.rb +24 -0
  119. data/db/migrate/20190327143921_add_campaign_to_message.rb +7 -0
  120. data/db/migrate/20190327155112_add_state_to_campaign.rb +7 -0
  121. data/db/migrate/20190412103335_add_enabled_to_templates.rb +7 -0
  122. data/db/migrate/20190417125153_change_message_status_default.rb +9 -0
  123. data/db/migrate/20190417144554_add_nuntiable_to_subscriber.rb +7 -0
  124. data/db/migrate/20190521135011_add_payload_to_nuntius_messages.rb +7 -0
  125. data/db/migrate/20190522122657_add_metadata_to_nuntius_message.rb +7 -0
  126. data/db/migrate/20190825080757_update_nuntius_message_sending_to_sent.rb +11 -0
  127. data/db/migrate/20200220154927_change_nuntius_templates_payload_type.rb +7 -0
  128. data/db/migrate/20200224132337_create_nuntius_locales.rb +13 -0
  129. data/db/migrate/20200318095339_create_nuntius_attachments.rb +12 -0
  130. data/db/migrate/20200407050646_add_interval_to_nuntius_template.rb +5 -0
  131. data/db/migrate/20200430131219_make_html_processing_optional.rb +6 -0
  132. data/db/migrate/20200430154032_make_html_processing_optional_revert.rb +6 -0
  133. data/db/migrate/20201121185718_create_nuntius_inbound_messages.rb +21 -0
  134. data/db/migrate/20220412114148_add_last_sent_to_message.rb +5 -0
  135. data/lib/nuntius/active_record_helpers.rb +28 -0
  136. data/lib/nuntius/active_storage_helpers.rb +8 -0
  137. data/lib/nuntius/configuration.rb +97 -0
  138. data/lib/nuntius/deprecator.rb +8 -0
  139. data/lib/nuntius/devise.rb +19 -0
  140. data/lib/nuntius/engine.rb +46 -0
  141. data/lib/nuntius/i18n_store.rb +100 -0
  142. data/lib/nuntius/liquid/tags/attach_tag.rb +44 -0
  143. data/lib/nuntius/mail_allow_list.rb +23 -0
  144. data/lib/nuntius/nuntiable.rb +24 -0
  145. data/lib/nuntius/state_machine.rb +19 -0
  146. data/lib/nuntius/transactio.rb +30 -0
  147. data/lib/nuntius/version.rb +3 -1
  148. data/lib/nuntius.rb +74 -8
  149. data/lib/preamble.rb +87 -0
  150. data/lib/tasks/nuntius_tasks.rake +27 -0
  151. metadata +532 -67
  152. data/.gitignore +0 -4
  153. data/Gemfile +0 -4
  154. data/lib/nuntius/encodings/url_safe_base64.rb +0 -26
  155. data/lib/nuntius/encodings.rb +0 -9
  156. data/lib/nuntius/envelope.rb +0 -45
  157. data/lib/nuntius/key.rb +0 -47
  158. data/lib/nuntius/messenger.rb +0 -37
  159. data/nuntius.gemspec +0 -23
  160. data/spec/keys/alice.pem +0 -27
  161. data/spec/keys/alice.pub +0 -9
  162. data/spec/keys/bob.pem +0 -27
  163. data/spec/keys/bob.pub +0 -9
  164. data/spec/nuntius/encodings/url_safe_base64_spec.rb +0 -36
  165. data/spec/nuntius/envelope_spec.rb +0 -6
  166. data/spec/nuntius/key_spec.rb +0 -12
  167. data/spec/nuntius/messenger_spec.rb +0 -26
  168. data/spec/spec_helper.rb +0 -9
  169. data/spec/support/keys.rb +0 -3
@@ -0,0 +1,56 @@
1
+ = sts.card title: [t('.message'), @message.template&.description], icon: 'fad fa-envelope' do |card|
2
+ - card.action
3
+ = button_to(t('nuntius.context_menu.resend'), resend_admin_message_path(@message), class: 'button')
4
+
5
+ - card.tab :preview, padding: true
6
+
7
+ table.table
8
+ thead
9
+ tr
10
+ th Name
11
+ th Value
12
+ tbody
13
+ tr
14
+ td To
15
+ td = @message.to
16
+
17
+ - if @message.transport == 'mail'
18
+ tr
19
+ td Subject
20
+ td = @message.subject
21
+ tr
22
+ td Attachments
23
+ td
24
+ - @message.attachments.each do |attachment|
25
+ = link_to(main_app.rails_blob_path(attachment, disposition: "attachment"), title: attachment.filename) do
26
+ i.far.fa-paperclip
27
+ span=attachment.filename
28
+ br
29
+
30
+ - if @message.transport == 'sms'
31
+ tr
32
+ td Text
33
+ td = @message.text
34
+
35
+ - if @message.transport == 'slack'
36
+ tr
37
+ td Text
38
+ td = @message.text
39
+ tr
40
+ td Payload
41
+ td
42
+ pre = YAML.dump(@message.payload)
43
+
44
+ - if @message.transport == 'mail' && @message.html.present?
45
+ iframe.border.rounded-lg.border-gray-200 src=message_path(@message.id) style="width: 100%; height: 600px; border: 0px;"
46
+
47
+ - card.tab :details, padding: true
48
+ = sts.info class: "grid grid-cols-1 gap-4 sm:grid-cols-3" do |info|
49
+ = info.item :status, content: @message.status, class: "sm:col-span-1"
50
+ = info.item :transport, content: @message.transport, class: "sm:col-span-1"
51
+ = info.item :provider, content: @message.provider, class: "sm:col-span-1"
52
+ = info.item :provider_id, content: @message.provider_id, class: "sm:col-span-1"
53
+ = info.item :request_id, content: @message.request_id, class: "sm:col-span-1"
54
+ = info.item :refreshes, content: @message.refreshes, class: "sm:col-span-1"
55
+ = info.item :last_sent_at, content: ln(@message.last_sent_at), class: "sm:col-span-1", icon: 'fal fa-envelope'
56
+ = info.item :created_at, content: ln(@message.created_at), class: "sm:col-span-1", icon: 'fal fa-calendar'
@@ -0,0 +1,81 @@
1
+
2
+ - present(@template, TemplatePresenter) do |template|
3
+ = sts.form_for([:admin, @template]) do |f|
4
+ = sts.card title: t('.template'), icon: 'fal fa-file' do |card|
5
+ - card.action
6
+ = f.continue
7
+ - card.action
8
+ = f.submit
9
+
10
+ = sts.tabs do |tabs|
11
+ - tabs.tab :edit
12
+ .grid.grid-cols-12.gap-4
13
+ .col-span-1
14
+ = f.input :enabled, as: :switch
15
+ .col-span-11
16
+ = f.input :description
17
+
18
+ .grid.grid-cols-12.gap-4 data-controller='toggle'
19
+ .col-span-6
20
+ = f.input :klass, collection: Nuntius.config.nuntiable_class_names.sort, selected: @template.klass, input_html: { data: { 'toggle-target' => 'input' } }
21
+
22
+ .col-span-6 data-toggle-target="insertion"
23
+
24
+ template data-toggle-target='toggleable' data-toggle-not-value='Custom'
25
+ .col-span-6.deze data-controller='toggle' data-toggle-attr='data-timebased'
26
+ .grid.grid-cols-12.gap-4
27
+ .col-span-6
28
+ = f.input :event, collection: template.all_events, include_blank: false, chain_to: 'template[klass]', input_html: { data: { 'toggle-target' => 'input' } }, as: :dropdown
29
+ .col-span-6 data-toggle-target="insertion"
30
+ template data-toggle-target='toggleable' data-toggle-value='true'
31
+ = f.input :interval
32
+
33
+ template data-toggle-target='toggleable' data-toggle-value='Custom'
34
+ .col-span-6
35
+ = f.input :event, input_html: { placeholder: 'scope#event' }
36
+
37
+ .grid.grid-cols-12.gap-4 data-controller='toggle'
38
+
39
+ .col-span-12
40
+ = f.input :transport, collection: Nuntius.config.transports, include_blank: false, input_html: { "data-toggle-target" => 'input' }
41
+
42
+ .col-span-6
43
+ = f.input :from
44
+ .col-span-6
45
+ = f.input :to
46
+
47
+ .col-span-12
48
+ .grid.grid-cols-12.gap-4 data-toggle-target="insertion"
49
+
50
+ .col-span-12
51
+ = f.input :metadata_yaml, as: :editor, mode: 'application/yaml', label: t('.metadata')
52
+
53
+ template data-toggle-target='toggleable' data-toggle-value='mail'
54
+ .col-span-12
55
+ = f.input :subject, as: :editor, mode: 'text/plain'
56
+ .col-span-12
57
+ = f.association :layout, collection: @layouts, include_blank: true
58
+ .col-span-12
59
+ = f.input :html, as: :editor, mode: 'text/markdown'
60
+
61
+ template data-toggle-target='toggleable' data-toggle-value='voice'
62
+ .col-span-12
63
+ = f.input :text, as: :editor, mode: 'text/plain'
64
+ template data-toggle-target='toggleable' data-toggle-value='slack'
65
+ .col-span-12
66
+ = f.input :text, as: :editor, mode: 'text/plain'
67
+ .col-span-12
68
+ = f.input :payload, as: :editor, mode: 'application/yaml'
69
+
70
+ template data-toggle-target='toggleable' data-toggle-value='sms'
71
+ .col-span-12
72
+ = f.input :text, as: :editor, mode: 'text/plain'
73
+ template data-toggle-target='toggleable' data-toggle-value='push'
74
+ .col-span-12
75
+ = f.input :text, as: :editor, mode: 'text/plain'
76
+ template data-toggle-target='toggleable' data-toggle-value='slack'
77
+
78
+
79
+ - if @template.messages.size.positive?
80
+ - tabs.tab :nuntius_messages, badge: @template.messages.size, padding: false
81
+ = sts.table :nuntius_messages, parameters: { template_id: @template.id }
@@ -0,0 +1,2 @@
1
+ = sts.card title: t('.templates'), icon: 'fad fa-language', content_padding: false, menu: nuntius_templates_menu do |card|
2
+ = sts.table :nuntius_templates
@@ -0,0 +1,7 @@
1
+ .grid.grid-cols-1.gap-4.sm:grid-cols-3
2
+ .col-span-3.sm:col-span-3
3
+ = reportlet(:'nuntius/daily_messages_per_template', parameters: { menu: :nuntius_dashboard_menu, template_ids: @templates.map(&:id)})
4
+
5
+ .col-span-3.sm:col-span-3
6
+ = sts.card title: t('.messages'), icon: 'fad fa-envelope', content_padding: false, menu: nuntius_dashboard_menu do |card|
7
+ = sts.table :nuntius_messages, parameters: {template_id: params[:template_id]}
@@ -0,0 +1,7 @@
1
+ = @message.html.html_safe
2
+ - @message.attachments.each do |attachment|
3
+ = link_to(attachment.filename, main_app.rails_blob_path(attachment, disposition: "attachment"), title: attachment.filename)
4
+ br
5
+
6
+ - content_for :context_menu do
7
+ =< link_to(t('nuntius.context_menu.root'), root_path, class: 'ui-button')
@@ -0,0 +1,22 @@
1
+ en:
2
+ nuntius:
3
+ flash:
4
+ error: There were problems saving the %{model}
5
+ notice: The %{model} was saved successfully
6
+ context_menu:
7
+ root: Root
8
+ resend: Resend
9
+ admin:
10
+ messages:
11
+ resend:
12
+ resend_success: Resent message
13
+ resend_error: Failed to resend message
14
+ breadcrumbs:
15
+ nuntius: Nuntius
16
+ dashboard: Dashboard
17
+ admin:
18
+ campaigns: Campaigns
19
+ messages: Messages
20
+ layouts: Layouts
21
+ lists: Lists
22
+ templates: Templates
@@ -0,0 +1,22 @@
1
+ nl:
2
+ nuntius:
3
+ flash:
4
+ error: Er waren problem om %{model} op te slaan
5
+ notice: De %{model} is sucesvol opgeslagen
6
+ context_menu:
7
+ root: Root
8
+ resend: Verstuur opnieuw
9
+ admin:
10
+ messages:
11
+ resend:
12
+ resend_success: Bericht opnieuw verstuurd
13
+ resend_error: Het is niet gelukt het bericht opnieuw te sturen
14
+ breadcrumbs:
15
+ nuntius: Nuntius
16
+ dashboard: Dashboard
17
+ admin:
18
+ campaigns: Campagnes
19
+ messages: Berichten
20
+ layouts: Layouts
21
+ lists: Lijsten
22
+ templates: Templates
data/config/routes.rb ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ Nuntius::Engine.routes.draw do
4
+ namespace :inbound_messages do
5
+ resource :twilio_inbound_smses
6
+ end
7
+
8
+ get 'callbacks/:message_id(/*path)', to: 'callbacks#create', as: :callback
9
+ post 'callbacks/:message_id(/*path)', to: 'callbacks#create'
10
+
11
+ post 'feedback/awssns' => 'feedback#awssns'
12
+
13
+ resources :messages
14
+ resources :campaigns
15
+
16
+ namespace :api do
17
+ resources :events
18
+ end
19
+
20
+ namespace :admin do
21
+ resources :campaigns
22
+ resources :layouts do
23
+ resources :attachments, controller: 'layouts/attachments'
24
+ end
25
+ resources :lists do
26
+ resources :subscribers, controller: 'lists/subscribers'
27
+ end
28
+ resources :messages do
29
+ member do
30
+ post 'resend', action: 'resend'
31
+ end
32
+ end
33
+ resources :layouts
34
+ resources :locales
35
+ resources :templates
36
+ end
37
+ root to: 'dashboard#show'
38
+ end
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,4 @@
1
+ const { environment } = require('@rails/webpacker')
2
+
3
+ module.exports = environment
4
+
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,119 @@
1
+ # Note: You must restart bin/webpack-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ source_path: app/javascript
5
+ source_entry_path: packs
6
+ public_root_path: public
7
+ public_output_path: packs
8
+ cache_path: tmp/cache/webpacker
9
+ check_yarn_integrity: false
10
+ webpack_compile_output: false
11
+
12
+ # Additional paths webpack should lookup modules
13
+ # ['app/assets', 'engine/foo/app/assets']
14
+ resolved_paths: []
15
+
16
+ # Reload manifest.json on all requests so we reload latest compiled packs
17
+ cache_manifest: false
18
+
19
+ # Extract and emit a css file
20
+ extract_css: true
21
+
22
+ static_assets_extensions:
23
+ - .jpg
24
+ - .jpeg
25
+ - .png
26
+ - .gif
27
+ - .tiff
28
+ - .ico
29
+ - .svg
30
+ - .eot
31
+ - .otf
32
+ - .ttf
33
+ - .woff
34
+ - .woff2
35
+
36
+ extensions:
37
+ - .mjs
38
+ - .js
39
+ - .sass
40
+ - .scss
41
+ - .css
42
+ - .module.sass
43
+ - .module.scss
44
+ - .module.css
45
+ - .png
46
+ - .svg
47
+ - .gif
48
+ - .jpeg
49
+ - .jpg
50
+
51
+ development:
52
+ <<: *default
53
+ compile: true
54
+
55
+ # Verifies that versions and hashed value of the package contents in the project's package.json
56
+ check_yarn_integrity: true
57
+
58
+ # Reference: https://webpack.js.org/configuration/dev-server/
59
+ dev_server:
60
+ https: false
61
+ host: localhost
62
+ port: 3035
63
+ public: localexpress.dev
64
+ hmr: true
65
+ # Inline should be set to true if using HMR
66
+ inline: true
67
+ overlay: true
68
+ compress: true
69
+ disable_host_check: true
70
+ use_local_ip: false
71
+ quiet: false
72
+ headers:
73
+ 'Access-Control-Allow-Origin': '*'
74
+ watch_options:
75
+ ignored: '**/node_modules/**'
76
+
77
+
78
+ test:
79
+ <<: *default
80
+ compile: true
81
+
82
+ # Compile test packs to a separate directory
83
+ public_output_path: packs-test
84
+
85
+ testing:
86
+ <<: *default
87
+
88
+ # Production depends on precompilation of packs prior to booting for performance.
89
+ compile: false
90
+
91
+ # Extract and emit a css file
92
+ extract_css: true
93
+
94
+ # Cache manifest.json for performance
95
+ cache_manifest: true
96
+
97
+ staging:
98
+ <<: *default
99
+
100
+ # Production depends on precompilation of packs prior to booting for performance.
101
+ compile: false
102
+
103
+ # Extract and emit a css file
104
+ extract_css: true
105
+
106
+ # Cache manifest.json for performance
107
+ cache_manifest: true
108
+
109
+ production:
110
+ <<: *default
111
+
112
+ # Production depends on precompilation of packs prior to booting for performance.
113
+ compile: false
114
+
115
+ # Extract and emit a css file
116
+ extract_css: true
117
+
118
+ # Cache manifest.json for performance
119
+ cache_manifest: true
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateNuntiusTemplates < ActiveRecord::Migration[5.1]
4
+ def change
5
+ enable_extension 'pgcrypto'
6
+
7
+ create_table :nuntius_templates, id: :uuid do |t|
8
+ t.string :klass
9
+ t.string :event
10
+ t.string :transport
11
+
12
+ t.string :description
13
+ t.jsonb :metadata, null: false, default: {}
14
+
15
+ t.references :layout, index: true, type: :uuid, foreign_key: { to_table: :nuntius_templates }
16
+
17
+ t.string :from
18
+ t.string :to
19
+ t.string :subject
20
+ t.text :html
21
+ t.text :text
22
+ t.jsonb :payload
23
+
24
+ t.timestamps
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateNuntiusMessages < ActiveRecord::Migration[5.1]
4
+ def change
5
+ enable_extension 'uuid-ossp'
6
+
7
+ create_table :nuntius_messages, id: :uuid do |t|
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
+ t.references :nuntiable, polymorphic: true, index: true, type: :uuid
11
+
12
+ t.integer :refreshes, default: 0
13
+
14
+ t.string :status, default: 'draft'
15
+ t.string :transport
16
+ t.string :provider
17
+ t.string :provider_id
18
+
19
+ t.string :request_id # For grouping
20
+
21
+ t.string :from
22
+ t.string :to
23
+ t.string :subject
24
+ t.text :html
25
+ t.text :text
26
+
27
+ t.timestamps
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateNuntiusLists < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :nuntius_lists, id: :uuid do |t|
6
+ t.string :name
7
+ t.integer :subscribers_count
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateNuntiusCampaigns < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :nuntius_campaigns, id: :uuid do |t|
6
+ t.string :name
7
+ t.string :transport, default: 'mail'
8
+ t.references :list, index: true, type: :uuid, foreign_key: { to_table: :nuntius_lists }
9
+
10
+ t.string :from
11
+ t.string :subject
12
+ t.text :text
13
+ t.text :html
14
+
15
+ t.timestamps
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateNuntiusSubscribers < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :nuntius_subscribers, id: :uuid do |t|
6
+ t.references :list, index: true, type: :uuid, foreign_key: { to_table: :nuntius_lists }
7
+
8
+ t.string :first_name
9
+ t.string :last_name
10
+ t.string :email
11
+ t.string :phone_number
12
+ t.string :tags
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddMetadataToModels < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :nuntius_campaigns, :metadata, :jsonb, null: false, default: {}
6
+ add_column :nuntius_lists, :metadata, :jsonb, null: false, default: {}
7
+ end
8
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateNuntiusLayouts < ActiveRecord::Migration[5.2]
4
+ def up
5
+ create_table :nuntius_layouts, id: :uuid do |t|
6
+ t.string :name
7
+
8
+ t.text :data
9
+ t.jsonb :metadata, null: false, default: {}
10
+
11
+ t.timestamps
12
+ end
13
+
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
+ end
18
+
19
+ def down
20
+ drop_table :nuntius_layouts
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
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddCampaignToMessage < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_reference :nuntius_messages, :campaign, type: :uuid, foreign_key: { to_table: :nuntius_campaigns }
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddStateToCampaign < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :nuntius_campaigns, :state, :string
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddEnabledToTemplates < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :nuntius_templates, :enabled, :boolean, default: true
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ChangeMessageStatusDefault < ActiveRecord::Migration[5.2]
4
+ def change
5
+ change_column_default(:nuntius_messages, :status, from: 'draft', to: 'pending')
6
+
7
+ Nuntius::Message.where(status: 'draft').update(status: 'pending')
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddNuntiableToSubscriber < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_reference :nuntius_subscribers, :nuntiable, polymorphic: true, index: true, type: :uuid
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddPayloadToNuntiusMessages < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :nuntius_messages, :payload, :jsonb
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddMetadataToNuntiusMessage < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :nuntius_messages, :metadata, :jsonb, default: {}
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UpdateNuntiusMessageSendingToSent < ActiveRecord::Migration[5.2]
4
+ def up
5
+ Nuntius::Message.where(status: 'sending').update_all(status: 'sent')
6
+ end
7
+
8
+ def down
9
+ Nuntius::Message.where(status: 'sent').update_all(status: 'sending')
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ChangeNuntiusTemplatesPayloadType < ActiveRecord::Migration[5.2]
4
+ def change
5
+ execute 'ALTER TABLE nuntius_templates ALTER COLUMN payload TYPE TEXT USING payload::text;'
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateNuntiusLocales < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :nuntius_locales, id: :uuid do |t|
6
+ t.string :key
7
+ t.jsonb :data
8
+ t.jsonb :metadata
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ class CreateNuntiusAttachments < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :nuntius_attachments, id: :uuid do |t|
4
+ t.timestamps
5
+ end
6
+
7
+ create_table :nuntius_attachments_messages, id: false do |t|
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
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ class AddIntervalToNuntiusTemplate < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :nuntius_templates, :interval, :string, null: true, default: nil
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ class MakeHtmlProcessingOptional < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :nuntius_templates, :html_inkyrb_processing, :boolean, default: true, null: false
4
+ add_column :nuntius_templates, :html_premailer_processing, :boolean, default: true, null: false
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class MakeHtmlProcessingOptionalRevert < ActiveRecord::Migration[5.2]
2
+ def change
3
+ remove_column :nuntius_templates, :html_inkyrb_processing, :boolean
4
+ remove_column :nuntius_templates, :html_premailer_processing, :boolean
5
+ end
6
+ end