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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dadbe5b3ded5dffcb6ceba8c5630fcce1d02905030087f3ac2fe7a5b0e94c0d
|
4
|
+
data.tar.gz: 909fce72b52db1d9b24c2445a6e13767564f56f633fee205eeb0b8e497ed407f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 617adffb4414a45c2eb885666a030225b7338d736ead1960bce4aae499960c4123de259c48bdf04584e033b65809abf1e4cfe076e24c67961508c66ecdaea27b
|
7
|
+
data.tar.gz: 1b8dba96defc70f262b455bbcd5ae87e5313e96e891910075eede92027c07811e524d1c25b83f0776b649b40e5bc1e11d0a771193069efa7f6bb52328f3d948d
|
data/README.md
CHANGED
@@ -159,14 +159,12 @@ Nuntius.event('packed', packing: {smurrefluts: 'hatseflats'})
|
|
159
159
|
|
160
160
|
The main key of the hash passed will also be the liquid variable.
|
161
161
|
|
162
|
-
### Inbound
|
163
|
-
|
164
|
-
Inbound messages are also possible, currently mail/IMAP and Twilio inbound SMS are supported.
|
165
|
-
|
166
162
|
## Transports
|
167
163
|
|
168
164
|
### Mail
|
169
165
|
|
166
|
+
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
|
+
|
170
168
|
#### AWS SES
|
171
169
|
|
172
170
|
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):
|
@@ -179,27 +177,47 @@ The subscription will automatically be confirmed.
|
|
179
177
|
|
180
178
|
Next in AWS SES, configure the SNS topic to receive feedback notifications for Bounce, Complaint and Delivery and include original headers.
|
181
179
|
|
180
|
+
### Slack
|
181
|
+
|
182
|
+
Slack uses the [postMessage](https://api.slack.com/methods/chat.postMessage) method to send messages. It will also upload any attachment the message has prior to sending the message itself.
|
183
|
+
|
184
|
+
The message body is specified using `text` and additionally supports the `payload` parameter.
|
185
|
+
|
186
|
+
The payload is merged with the `text`, `to` (channel or user) and `from`.
|
187
|
+
|
188
|
+
### Teams
|
189
|
+
|
190
|
+
For Microsoft Teams you need to have the webhook URL for a channel. You right-click the channel (not the team) and click "Manage channel".
|
191
|
+
Then on the settings click "Edit" under "Manage the connectors that post to this channel", then search for "Incoming Webhook" and add it and configure it.
|
192
|
+
You can give it a name and an image.
|
193
|
+
|
194
|
+
See [Create Incoming Webhooks](https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook?tabs=newteams%2Cdotnet) for details.
|
195
|
+
|
182
196
|
### SMS
|
183
197
|
|
184
|
-
|
198
|
+
SMS just support the `from` (name or phone number), `to` (the phone) and `text` attribute.
|
199
|
+
|
200
|
+
Only MessageBird allows for names when sending SMS messages. Messagebird does not support a hypen in the name, just alphabetical characters (A-Za-z).
|
185
201
|
|
186
202
|
### Voice
|
187
203
|
|
188
|
-
|
204
|
+
Currently only Twilio voice is supported in the voice transport.
|
205
|
+
|
206
|
+
Information on voice TWIML is here: https://www.twilio.com/docs/voice/twiml
|
207
|
+
You can try voices here: https://www.twilio.com/docs/voice/twiml/say/text-speech
|
189
208
|
|
190
|
-
|
191
|
-
You can try voices here: https://www.twilio.com/console/voice/twiml/text-to-speech
|
209
|
+
The Voice transport is particularly nice, because you can define whole paths in the message body, for example:
|
192
210
|
|
193
211
|
```
|
194
212
|
<?xml version="1.0" encoding="UTF-8"?>
|
195
213
|
<Response>
|
196
|
-
<Say language="
|
197
|
-
|
214
|
+
<Say language="en-US">
|
215
|
+
Hello Earthling, this is a message from your Robot Overlords!
|
198
216
|
<break strength="x-weak" time="100ms"/>
|
199
|
-
<p>We
|
217
|
+
<p>We will soon give you your escape-hatch-code, so grab a pen and write it down.</p>
|
200
218
|
</Say>
|
201
219
|
<Gather input="dtmf" numDigits="1" action="{%raw%}{{url}}{%endraw%}/code">
|
202
|
-
<Say language="
|
220
|
+
<Say language="en-US">Press any key to continue.</Say>
|
203
221
|
</Gather>
|
204
222
|
<Redirect>{%raw%}{{url}}{%endraw%}/code</Redirect>
|
205
223
|
</Response>
|
@@ -210,20 +228,61 @@ path: /code
|
|
210
228
|
<?xml version="1.0" encoding="UTF-8"?>
|
211
229
|
<Response>
|
212
230
|
<Gather input="dtmf" numDigits="1">
|
213
|
-
<Say language="
|
214
|
-
<s>
|
231
|
+
<Say language="en-US">
|
232
|
+
<s>Your code is:</s>
|
215
233
|
<break strength="x-weak" time="100ms"/>
|
216
|
-
<prosody rate="x-slow"><say-as interpret-as="character">
|
234
|
+
<prosody rate="x-slow"><say-as interpret-as="character">s e n d h e l p</say-as></prosody>
|
217
235
|
<break strength="x-weak" time="1s"/>
|
218
|
-
|
236
|
+
Press any key to continue, or just hang up.
|
219
237
|
</Say>
|
220
238
|
</Gather>
|
221
239
|
<Redirect>{%raw%}{{url}}{%endraw%}/code</Redirect>
|
222
240
|
</Response>
|
223
241
|
```
|
224
242
|
|
225
|
-
|
243
|
+
### Inbound
|
244
|
+
|
245
|
+
Inbound messages are also possible, currently mail/IMAP and Twilio inbound SMS are supported.
|
246
|
+
This is done using message-boxes, for this to work you need to add a `message_boxes` folder to your `app` folder.
|
247
|
+
|
248
|
+
#### SMS
|
249
|
+
|
250
|
+
Twilio is currently the only supported inbound SMS provider.
|
251
|
+
Point Twilio to you nuntius mount path (/messaging/inbound_messages/twilio_inbound_smses)
|
252
|
+
|
253
|
+
```ruby
|
254
|
+
class FooMessageBox < Nuntius::BaseMessageBox
|
255
|
+
transport :sms
|
256
|
+
provider :twilio
|
226
257
|
|
258
|
+
route /\+31.+/, to: :dutchies
|
259
|
+
end
|
227
260
|
```
|
228
|
-
|
261
|
+
|
262
|
+
#### Mail
|
263
|
+
Nuntius will look at a mailbox and for each of the mails will check whether it can find a route for it in any of the message-boxes.
|
264
|
+
After delivery, on the next round of fetching mail, nuntius will move processed message to the Archive folder
|
265
|
+
|
266
|
+
```ruby
|
267
|
+
class BarMessageBox < Nuntius::BaseMessageBox
|
268
|
+
transport :mail
|
269
|
+
provider :imap
|
270
|
+
|
271
|
+
settings({
|
272
|
+
address: 'imap.gmail.com',
|
273
|
+
port: 993,
|
274
|
+
user_name: '',
|
275
|
+
password: '',
|
276
|
+
authentication: '',
|
277
|
+
enable_ssl: false,
|
278
|
+
enable_starttls: false
|
279
|
+
})
|
280
|
+
|
281
|
+
route to: :process
|
282
|
+
|
283
|
+
def process
|
284
|
+
puts message.status # Message is Nuntius's inbound message.
|
285
|
+
puts mail.to
|
286
|
+
end
|
287
|
+
end
|
229
288
|
```
|
data/Rakefile
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
begin
|
4
|
-
require
|
4
|
+
require "bundler/setup"
|
5
5
|
rescue LoadError
|
6
|
-
puts
|
6
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
7
7
|
end
|
8
8
|
|
9
|
-
require
|
9
|
+
require "rdoc/task"
|
10
10
|
|
11
11
|
RDoc::Task.new(:rdoc) do |rdoc|
|
12
|
-
rdoc.rdoc_dir =
|
13
|
-
rdoc.title
|
14
|
-
rdoc.options <<
|
15
|
-
rdoc.rdoc_files.include(
|
16
|
-
rdoc.rdoc_files.include(
|
12
|
+
rdoc.rdoc_dir = "rdoc"
|
13
|
+
rdoc.title = "Nuntius"
|
14
|
+
rdoc.options << "--line-numbers"
|
15
|
+
rdoc.rdoc_files.include("README.md")
|
16
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
17
17
|
end
|
18
18
|
|
19
|
-
APP_RAKEFILE = File.expand_path(
|
20
|
-
load
|
19
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
20
|
+
load "rails/tasks/engine.rake"
|
21
21
|
|
22
|
-
load
|
22
|
+
load "rails/tasks/statistics.rake"
|
23
23
|
|
24
|
-
require
|
24
|
+
require "bundler/gem_tasks"
|
25
25
|
|
26
|
-
require
|
26
|
+
require "rake/testtask"
|
27
27
|
|
28
28
|
Rake::TestTask.new(:test) do |t|
|
29
|
-
t.libs <<
|
30
|
-
t.pattern =
|
29
|
+
t.libs << "test"
|
30
|
+
t.pattern = "test/**/*_test.rb"
|
31
31
|
t.verbose = false
|
32
32
|
t.warning = false
|
33
33
|
end
|
@@ -35,28 +35,5 @@ end
|
|
35
35
|
task default: :test
|
36
36
|
|
37
37
|
# Adds the Auxilium semver task
|
38
|
-
spec = Gem::Specification.find_by_name
|
38
|
+
spec = Gem::Specification.find_by_name "auxilium"
|
39
39
|
load "#{spec.gem_dir}/lib/tasks/semver.rake"
|
40
|
-
|
41
|
-
namespace :nuntius do
|
42
|
-
namespace :webpacker do
|
43
|
-
desc 'Install deps with yarn'
|
44
|
-
task :yarn_install do
|
45
|
-
Dir.chdir(File.join(__dir__, '../..')) do
|
46
|
-
system 'yarn install --no-progress --production'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
desc 'Compile JavaScript packs using webpack for production with digests'
|
51
|
-
task compile: %i[yarn_install environment] do
|
52
|
-
Webpacker.with_node_env('production') do
|
53
|
-
if Nuntius.webpacker.commands.compile
|
54
|
-
# Successful compilation!
|
55
|
-
else
|
56
|
-
# Failed compilation
|
57
|
-
exit!
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_dependency
|
3
|
+
require_dependency "nuntius/application_admin_controller"
|
4
4
|
|
5
5
|
module Nuntius
|
6
6
|
module Admin
|
@@ -24,17 +24,19 @@ module Nuntius
|
|
24
24
|
redirect_to :edit_admin_campaign, status: :see_other
|
25
25
|
end
|
26
26
|
|
27
|
-
def edit
|
27
|
+
def edit
|
28
|
+
end
|
28
29
|
|
29
30
|
def update
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
@campaign.update(campaign_params)
|
32
|
+
|
33
|
+
respond_with :admin, @campaign
|
34
|
+
end
|
35
|
+
|
36
|
+
def publish
|
37
|
+
@campaign.publish! if @campaign.can_publish?
|
38
|
+
|
39
|
+
redirect_to :admin_campaigns, status: :see_other
|
38
40
|
end
|
39
41
|
|
40
42
|
private
|
@@ -1,11 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_dependency
|
3
|
+
require_dependency "nuntius/application_admin_controller"
|
4
4
|
|
5
5
|
module Nuntius
|
6
6
|
module Admin
|
7
7
|
class ListsController < ApplicationAdminController
|
8
|
-
|
9
8
|
def index
|
10
9
|
@lists = Nuntius::List.visible.order(:name)
|
11
10
|
end
|
@@ -36,10 +35,11 @@ module Nuntius
|
|
36
35
|
|
37
36
|
private
|
38
37
|
|
39
|
-
def set_objects
|
38
|
+
def set_objects
|
39
|
+
end
|
40
40
|
|
41
41
|
def list_params
|
42
|
-
params.require(:list).permit(:name)
|
42
|
+
params.require(:list).permit(:name, :slug, :allow_unsubscribe, :description, :metadata_yaml)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_dependency
|
3
|
+
require_dependency "nuntius/application_admin_controller"
|
4
4
|
|
5
5
|
module Nuntius
|
6
6
|
module Admin
|
@@ -36,7 +36,8 @@ module Nuntius
|
|
36
36
|
|
37
37
|
private
|
38
38
|
|
39
|
-
def set_objects
|
39
|
+
def set_objects
|
40
|
+
end
|
40
41
|
|
41
42
|
def locale_params
|
42
43
|
params.require(:locale).permit(:key, :data, :metadata_yaml, :data_yaml)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_dependency
|
3
|
+
require_dependency "nuntius/application_admin_controller"
|
4
4
|
|
5
5
|
module Nuntius
|
6
6
|
module Admin
|
@@ -17,7 +17,7 @@ module Nuntius
|
|
17
17
|
def resend
|
18
18
|
@message = Nuntius::Message.visible.find(params[:id])
|
19
19
|
@message.resend
|
20
|
-
respond_with @message, success: t(
|
20
|
+
respond_with @message, success: t(".resend_success"), error: t(".resend_error")
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_dependency
|
3
|
+
require_dependency "nuntius/application_controller"
|
4
4
|
|
5
5
|
module Nuntius
|
6
6
|
class Api::EventsController < ApplicationController
|
@@ -10,7 +10,7 @@ module Nuntius
|
|
10
10
|
|
11
11
|
def create
|
12
12
|
nuntius_params = params.except(:scope, :event, :context, :controller, :action).permit!.to_h
|
13
|
-
Nuntius.event(params[:event], {
|
13
|
+
Nuntius.event(params[:event], {params[:scope] => params[:context].permit!.to_h}, nuntius_params)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_dependency
|
4
|
-
require
|
3
|
+
require_dependency "nuntius/application_controller"
|
4
|
+
require "preamble"
|
5
5
|
|
6
6
|
module Nuntius
|
7
7
|
class CallbacksController < ApplicationController
|
@@ -14,8 +14,8 @@ module Nuntius
|
|
14
14
|
response = message.nuntius_provider(message).callback(params)
|
15
15
|
|
16
16
|
render body: response[2].first,
|
17
|
-
|
18
|
-
|
17
|
+
content_type: response[1]["Content-Type"],
|
18
|
+
layout: false
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_dependency
|
4
|
-
require
|
3
|
+
require_dependency "nuntius/application_controller"
|
4
|
+
require "twilio-ruby"
|
5
5
|
|
6
6
|
module Nuntius
|
7
7
|
module InboundMessages
|
@@ -29,27 +29,27 @@ module Nuntius
|
|
29
29
|
# 'NumSegments' => '1',
|
30
30
|
# 'MessageSid' => 'SMb711289e438f577f230f5837e9c74a08',
|
31
31
|
# 'AccountSid' => 'ACf54dd7a47a8011d65b54d472a7190549',
|
32
|
-
# 'From' => '+
|
32
|
+
# 'From' => '+31612345678',
|
33
33
|
# 'ApiVersion' => '2010-04-01',
|
34
34
|
# 'controller' => 'nuntius/inbound_messages/twilio_inbound_smses',
|
35
35
|
# 'action' => 'create' }
|
36
36
|
def create
|
37
|
-
inbound_message = Nuntius::InboundMessage.find_or_create_by!(transport:
|
37
|
+
inbound_message = Nuntius::InboundMessage.find_or_create_by!(transport: "sms", provider: "twilio", provider_id: params[:SmsSid])
|
38
38
|
inbound_message.from = params[:From]
|
39
39
|
inbound_message.to = params[:To]
|
40
40
|
inbound_message.text = params[:Body]
|
41
41
|
inbound_message.metadata = params
|
42
42
|
inbound_message.save!
|
43
43
|
|
44
|
-
twiml = Nuntius::DeliverInboundMessageService.
|
44
|
+
twiml = Nuntius::DeliverInboundMessageService.perform(inbound_message: inbound_message)
|
45
45
|
|
46
46
|
# twiml = Twilio::TwiML::MessagingResponse.new do |resp|
|
47
47
|
# resp.message body: 'The Robots are coming! Head for the hills!'
|
48
48
|
# end
|
49
49
|
|
50
50
|
render body: twiml.to_s,
|
51
|
-
|
52
|
-
|
51
|
+
content_type: "text/xml",
|
52
|
+
layout: false
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency "nuntius/application_controller"
|
4
|
+
|
5
|
+
module Nuntius
|
6
|
+
class SubscribersController < ApplicationController
|
7
|
+
# skip_before_action :authenticate_user!, only: %i[show destroy]
|
8
|
+
|
9
|
+
def show
|
10
|
+
@subscriber = Nuntius::Subscriber.find_by(id: params[:id])
|
11
|
+
if @subscriber
|
12
|
+
@list = @subscriber.list
|
13
|
+
else
|
14
|
+
flash[:notice] = "Subscription not found."
|
15
|
+
redirect_to root_path, status: :see_other
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def subscribe
|
20
|
+
@subscriber = Nuntius::Subscriber.find(params[:id])
|
21
|
+
@subscriber.update(unsubscribed_at: nil)
|
22
|
+
flash[:notice] = "Subscription has been restored."
|
23
|
+
redirect_to nuntius.subscriber_path(@subscriber), status: :see_other
|
24
|
+
end
|
25
|
+
|
26
|
+
def unsubscribe
|
27
|
+
@subscriber = Nuntius::Subscriber.find(params[:id])
|
28
|
+
@subscriber.touch(:unsubscribed_at)
|
29
|
+
flash[:notice] = "Subscription has been removed."
|
30
|
+
redirect_to nuntius.subscriber_path(@subscriber), status: :see_other
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -4,11 +4,12 @@ module Nuntius
|
|
4
4
|
module ApplicationHelper
|
5
5
|
def nuntius_dashboard_menu
|
6
6
|
Satis::Menus::Builder.build(:dashboard) do |m|
|
7
|
-
m.item :
|
8
|
-
m.item :
|
9
|
-
m.item :
|
10
|
-
m.item :
|
11
|
-
m.item :
|
7
|
+
m.item :messages, link: nuntius.admin_messages_path, icon: "fal fa-envelope"
|
8
|
+
m.item :templates, link: nuntius.admin_templates_path, icon: "fal fa-file"
|
9
|
+
m.item :layouts, link: nuntius.admin_layouts_path, icon: "fal fa-table-layout"
|
10
|
+
m.item :locales, link: nuntius.admin_locales_path, icon: "fal fa-language"
|
11
|
+
m.item :campaigns, link: nuntius.admin_campaigns_path, icon: "fal fa-megaphone"
|
12
|
+
m.item :lists, link: nuntius.admin_lists_path, icon: "fal fa-address-book"
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
@@ -18,12 +19,6 @@ module Nuntius
|
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
|
-
def nuntius_messages_menu
|
22
|
-
Satis::Menus::Builder.build(:messages) do |m|
|
23
|
-
m.item :new, link: nuntius.new_admin_message_path
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
22
|
def nuntius_layouts_menu
|
28
23
|
Satis::Menus::Builder.build(:layouts) do |m|
|
29
24
|
m.item :new, link: nuntius.new_admin_layout_path
|
@@ -2,8 +2,8 @@ module Nuntius
|
|
2
2
|
class PurgeMessageJob < ApplicationJob
|
3
3
|
def perform(account_id, months)
|
4
4
|
messages = Nuntius::Message.distinct.select(:id).where("metadata ->> 'account_id' = :account", account: account_id)
|
5
|
-
|
6
|
-
|
5
|
+
.where(created_at: ..months.months.ago.beginning_of_day)
|
6
|
+
.where.not(status: %w[complaint bounced])
|
7
7
|
|
8
8
|
Nuntius::Message.where(parent_message_id: messages.pluck(:id)).in_batches.update_all(parent_message_id: nil)
|
9
9
|
|
@@ -7,10 +7,10 @@ module Nuntius
|
|
7
7
|
klasses = Nuntius::BaseMessageBox.message_box_for(transport: :mail)
|
8
8
|
|
9
9
|
klasses.each do |klass|
|
10
|
-
RetrieveInboundMailService.
|
10
|
+
RetrieveInboundMailService.perform(settings: klass.settings)
|
11
11
|
end
|
12
12
|
|
13
|
-
Nuntius::InboundMessage.where(status:
|
13
|
+
Nuntius::InboundMessage.where(status: "pending").each do |message|
|
14
14
|
Nuntius::DeliverInboundMessageJob.perform_later(message)
|
15
15
|
end
|
16
16
|
end
|
@@ -11,8 +11,8 @@ module Nuntius
|
|
11
11
|
original_message = message
|
12
12
|
message = message.dup
|
13
13
|
message.parent_message = original_message
|
14
|
-
message.status =
|
15
|
-
message.provider_id =
|
14
|
+
message.status = "pending"
|
15
|
+
message.provider_id = ""
|
16
16
|
end
|
17
17
|
message.provider = provider_name
|
18
18
|
message.save!
|