nuntius 1.4.5 → 1.4.7
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 +42 -0
- data/app/jobs/nuntius/application_job.rb +1 -0
- data/app/jobs/nuntius/messenger_job.rb +0 -9
- data/app/models/nuntius/concerns/events_transaction.rb +7 -2
- data/app/models/nuntius/message.rb +1 -1
- data/app/tables/nuntius/messages_table.rb +8 -0
- data/db/migrate/20260123160443_change_nuntius_events_id.rb +12 -0
- data/lib/nuntius/version.rb +1 -1
- metadata +3 -17
- data/app/providers/nuntius/houston_push_provider.rb +0 -40
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 60ba6bdae28e285f54ae11261866c96857711e32dc2d8f066a39f01acfff444f
|
|
4
|
+
data.tar.gz: f0044e290dc4e32eee2eb7ce024e74325aa437846b304920f2d31d1f211e43d5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 05ba146b1ee291c41819bef8041ed961c6c93c52ffa0474e9522e9e2e5a37657427d61aca8bb387233c6c1c3f641189113dcdd986bfa8f0a1fe137e4266be607
|
|
7
|
+
data.tar.gz: d23e9470ad3bc65cc2b1a0f3134d5f45367afcabd152d3e936998142edf67e91a22122fa8b712b3fc49710e609804cc8ce62c7e96d0e99d2f4c2db71acdfe12d
|
data/README.md
CHANGED
|
@@ -152,6 +152,48 @@ Beter even is using Sidekiq::Cron or GoodJob
|
|
|
152
152
|
Nuntius will automatically prevent sending duplicates within the timerange you define.
|
|
153
153
|
It will also ONLY send messages for objects (the one in template class), created after you created this template, this prevents sending dozens of emails which may make no sense, when you add a new template.
|
|
154
154
|
|
|
155
|
+
### Locales
|
|
156
|
+
|
|
157
|
+
Nuntius supports locale support in it's mails. You can add locales for your emails per language:
|
|
158
|
+
|
|
159
|
+
Add a locale with key `en`:
|
|
160
|
+
```yaml
|
|
161
|
+
en:
|
|
162
|
+
salutation: "Hello %{name}"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Then in your template you can do:
|
|
166
|
+
```liquid
|
|
167
|
+
{{'salutation' | t name: {{car.owner}} }}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Metadata
|
|
171
|
+
|
|
172
|
+
You can use metadata in your template to guide some text and information in your layout.
|
|
173
|
+
|
|
174
|
+
Say you need to change the header of an email, based on the template. In your layout you can then do this:
|
|
175
|
+
|
|
176
|
+
```html
|
|
177
|
+
<h2>{{template.metadata.header}}</h2>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
And in you template metadata:
|
|
181
|
+
|
|
182
|
+
```yaml
|
|
183
|
+
header: You lost your password?
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Say your layout has a logo image, which needs to change based on the brand of the car.
|
|
187
|
+
In your layout html you can do the following, to grab
|
|
188
|
+
|
|
189
|
+
```html
|
|
190
|
+
<img src="{%render template.metadata.logo_url%}" alt="logo"/>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
in your template metadata:
|
|
194
|
+
```yaml
|
|
195
|
+
logo_path: "{{car.brand.logo_path}}"
|
|
196
|
+
```
|
|
155
197
|
### Direct
|
|
156
198
|
|
|
157
199
|
Another more direct way of using Nuntius is by just instantiating a message:
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
# Initializes the appropriate Messenger class and calls the event method
|
|
4
4
|
module Nuntius
|
|
5
5
|
class MessengerJob < ApplicationJob
|
|
6
|
-
after_perform :cleanup_nuntius_events
|
|
7
|
-
|
|
8
6
|
def perform(obj, event, params = {})
|
|
9
7
|
return unless obj
|
|
10
8
|
|
|
@@ -19,12 +17,5 @@ module Nuntius
|
|
|
19
17
|
messenger.dispatch(templates) if templates.exists?
|
|
20
18
|
end
|
|
21
19
|
end
|
|
22
|
-
|
|
23
|
-
def cleanup_nuntius_events
|
|
24
|
-
Nuntius::Event.where(
|
|
25
|
-
transitionable: arguments.first,
|
|
26
|
-
transition_event: arguments.second.to_s
|
|
27
|
-
).delete_all
|
|
28
|
-
end
|
|
29
20
|
end
|
|
30
21
|
end
|
|
@@ -31,10 +31,15 @@ module Nuntius
|
|
|
31
31
|
|
|
32
32
|
def dispatch_nuntius_events
|
|
33
33
|
Nuntius::Event
|
|
34
|
-
.where(transitionable_type: self.class.name,transitionable_id:
|
|
34
|
+
.where(transitionable_type: self.class.name, transitionable_id: id)
|
|
35
35
|
.includes(:transitionable)
|
|
36
|
-
.select(:transition_event, :transitionable_type, :transitionable_id).distinct.each do |event|
|
|
36
|
+
.select(:transition_event, :transition_attribute, :transitionable_type, :transitionable_id).distinct.each do |event|
|
|
37
37
|
Nuntius.event(event.transition_event.to_sym, event.transitionable)
|
|
38
|
+
|
|
39
|
+
# Immediately cleanup the events after dispatching
|
|
40
|
+
Nuntius::Event.where(transitionable_type: self.class.name, transitionable_id: id,
|
|
41
|
+
transition_event: event.transition_event.to_s,
|
|
42
|
+
transition_attribute: event.transition_attribute).delete_all
|
|
38
43
|
end
|
|
39
44
|
end
|
|
40
45
|
end
|
|
@@ -69,7 +69,7 @@ module Nuntius
|
|
|
69
69
|
# FIXME: This is a possible security problem
|
|
70
70
|
attachment[:io] = File.open(uri.path)
|
|
71
71
|
elsif uri
|
|
72
|
-
client = Faraday.new
|
|
72
|
+
client = Faraday.new do |builder|
|
|
73
73
|
builder.response :follow_redirects
|
|
74
74
|
builder.adapter Faraday.default_adapter
|
|
75
75
|
end
|
|
@@ -2,12 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
module Nuntius
|
|
4
4
|
class MessagesTable < Nuntius::ApplicationTable
|
|
5
|
+
|
|
5
6
|
definition do
|
|
6
7
|
model Nuntius::Message
|
|
7
8
|
|
|
8
9
|
column(:to)
|
|
9
10
|
column(:created_at)
|
|
10
11
|
column(:last_sent_at)
|
|
12
|
+
action :resend do
|
|
13
|
+
link { |message| nuntius.resend_admin_message_path(message) }
|
|
14
|
+
icon "fal fa-rotate-right"
|
|
15
|
+
link_attributes data: {"turbo-confirm": "Are you sure you want to resend the message?", "turbo-method": :post}
|
|
16
|
+
show ->(message) { true }
|
|
17
|
+
end
|
|
18
|
+
|
|
11
19
|
column(:campaign_id) do
|
|
12
20
|
render do
|
|
13
21
|
html do |message|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class ChangeNuntiusEventsId < ActiveRecord::Migration[8.1]
|
|
2
|
+
def change
|
|
3
|
+
execute "DELETE FROM public.nuntius_events;"
|
|
4
|
+
add_column :nuntius_events, :uuid, :uuid, default: "gen_random_uuid()", null: false
|
|
5
|
+
|
|
6
|
+
change_table :nuntius_events do |t|
|
|
7
|
+
t.remove :id
|
|
8
|
+
t.rename :uuid, :id
|
|
9
|
+
end
|
|
10
|
+
execute "ALTER TABLE nuntius_events ADD PRIMARY KEY (id);"
|
|
11
|
+
end
|
|
12
|
+
end
|
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.4.
|
|
4
|
+
version: 1.4.7
|
|
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:
|
|
11
|
+
date: 2026-01-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: apnotic
|
|
@@ -66,20 +66,6 @@ dependencies:
|
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '1.0'
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: houston
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - "~>"
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: '2.4'
|
|
76
|
-
type: :runtime
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - "~>"
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: '2.4'
|
|
83
69
|
- !ruby/object:Gem::Dependency
|
|
84
70
|
name: faraday
|
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -497,7 +483,6 @@ files:
|
|
|
497
483
|
- app/providers/nuntius/apnotic_push_provider.rb
|
|
498
484
|
- app/providers/nuntius/base_provider.rb
|
|
499
485
|
- app/providers/nuntius/firebase_push_provider.rb
|
|
500
|
-
- app/providers/nuntius/houston_push_provider.rb
|
|
501
486
|
- app/providers/nuntius/message_bird_sms_provider.rb
|
|
502
487
|
- app/providers/nuntius/slack_slack_provider.rb
|
|
503
488
|
- app/providers/nuntius/smstools_sms_provider.rb
|
|
@@ -573,6 +558,7 @@ files:
|
|
|
573
558
|
- db/migrate/20240206203019_add_slug_to_nuntius_list.rb
|
|
574
559
|
- db/migrate/20250520091916_create_nuntius_events_table.rb
|
|
575
560
|
- db/migrate/20250521132554_update_nuntius_events_index.rb
|
|
561
|
+
- db/migrate/20260123160443_change_nuntius_events_id.rb
|
|
576
562
|
- lib/generators/nuntius/install_generator.rb
|
|
577
563
|
- lib/generators/nuntius/tailwind_config_generator.rb
|
|
578
564
|
- lib/generators/nuntius/templates/config/initializers/nuntius.rb
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "houston"
|
|
4
|
-
|
|
5
|
-
module Nuntius
|
|
6
|
-
class HoustonPushProvider < BaseProvider
|
|
7
|
-
transport :push
|
|
8
|
-
|
|
9
|
-
setting_reader :certificate,
|
|
10
|
-
required: true,
|
|
11
|
-
description: "The contents of a valid APNS push certificate in .pem format"
|
|
12
|
-
setting_reader :passphrase,
|
|
13
|
-
required: false,
|
|
14
|
-
description: "If the APNS certificate is protected by a passphrase, " \
|
|
15
|
-
"provide this variable to use when decrypting it."
|
|
16
|
-
setting_reader :environment,
|
|
17
|
-
required: false,
|
|
18
|
-
default: :production,
|
|
19
|
-
description: "Development or production, defaults to production"
|
|
20
|
-
|
|
21
|
-
def deliver
|
|
22
|
-
return message if message.to.size != 64
|
|
23
|
-
|
|
24
|
-
apn = (environment.to_sym == :development) ? Houston::Client.development : Houston::Client.production
|
|
25
|
-
apn.certificate = certificate
|
|
26
|
-
apn.passphrase = passphrase
|
|
27
|
-
|
|
28
|
-
notification = Houston::Notification.new((message.payload || {}).merge(device: message.to,
|
|
29
|
-
alert: message.text, sound: "default"))
|
|
30
|
-
apn.push(notification)
|
|
31
|
-
|
|
32
|
-
message.status = if notification.sent?
|
|
33
|
-
"sent"
|
|
34
|
-
elsif !notification.valid? || notification.error
|
|
35
|
-
"undelivered"
|
|
36
|
-
end
|
|
37
|
-
message
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|