noticed 1.5.9 → 1.6.0
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 +19 -16
- data/lib/generators/noticed/templates/README +1 -1
- data/lib/noticed/base.rb +4 -0
- data/lib/noticed/coder.rb +2 -0
- data/lib/noticed/model.rb +5 -0
- data/lib/noticed/version.rb +1 -1
- data/lib/noticed.rb +1 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eade1cdb53653ae77fa61a1348340402ea37625188677a16baddda26bc42bd49
|
4
|
+
data.tar.gz: 11d1d9ba60517005306714fc028fd312bbee7bef489d19218e7ba5c6938e22eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08b57a6181fa23484fa7c21eb7153a75c2bb05750532d2c649a8bc46e30b57be8041039802396167e639fede5595c64bb09d683eaeb1f23a0b0d346f2e76ca5e'
|
7
|
+
data.tar.gz: cc01ee47a638c02f1e5311c1433735607052130be9b4beaf61ced7482fd31910ab8c8a17915ff9c60a50bccddbc86bcb14f44519d8119632a95a1eba214f22a4
|
data/README.md
CHANGED
@@ -194,6 +194,8 @@ deliver_by :slack, debug: true
|
|
194
194
|
|
195
195
|
## ✅ Best Practices
|
196
196
|
|
197
|
+
### Creating a notification from an Active Record callback
|
198
|
+
|
197
199
|
A common use case is to trigger a notification when a record is created. For example,
|
198
200
|
|
199
201
|
```ruby
|
@@ -217,6 +219,23 @@ A common symptom of this problem is undelivered notifications and the following
|
|
217
219
|
|
218
220
|
> `Discarded Noticed::DeliveryMethods::Email due to a ActiveJob::DeserializationError.`
|
219
221
|
|
222
|
+
### Renaming notifications
|
223
|
+
|
224
|
+
If you rename the class of a notification object your existing queries can break. This is because Noticed serializes the class name and sets it to the `type` column on the `Notification` record.
|
225
|
+
|
226
|
+
You can catch these errors at runtime by using `YourNotificationClassName.name` instead of hardcoding the string when performing a query.
|
227
|
+
|
228
|
+
```ruby
|
229
|
+
Notification.where(type: YourNotificationClassName.name) # good
|
230
|
+
Notification.where(type: "YourNotificationClassName") # bad
|
231
|
+
```
|
232
|
+
|
233
|
+
When renaming a notification class you will need to backfill existing notifications to reference the new name.
|
234
|
+
|
235
|
+
```ruby
|
236
|
+
Notification.where(type: "OldNotificationClassName").update_all(type: NewNotificationClassName.name)
|
237
|
+
```
|
238
|
+
|
220
239
|
## 🚛 Delivery Methods
|
221
240
|
|
222
241
|
The delivery methods are designed to be modular so you can customize the way each type gets delivered.
|
@@ -351,22 +370,6 @@ class DeliveryMethods::Discord < Noticed::DeliveryMethods::Base
|
|
351
370
|
end
|
352
371
|
```
|
353
372
|
|
354
|
-
#### Limitations
|
355
|
-
|
356
|
-
Rails 6.1+ can serialize Class and Module objects as arguments to ActiveJob. The following syntax should work for Rails 6.1+:
|
357
|
-
|
358
|
-
```ruby
|
359
|
-
deliver_by DeliveryMethods::Discord
|
360
|
-
```
|
361
|
-
|
362
|
-
For Rails 5.2 and 6.0, you must pass strings of the class names in the `deliver_by` options.
|
363
|
-
|
364
|
-
```ruby
|
365
|
-
deliver_by :discord, class: "DeliveryMethods::Discord"
|
366
|
-
```
|
367
|
-
|
368
|
-
We recommend using a string in order to prevent confusion.
|
369
|
-
|
370
373
|
### 📦 Database Model
|
371
374
|
|
372
375
|
The Notification database model includes several helpful features to make working with database notifications easier.
|
@@ -3,5 +3,5 @@
|
|
3
3
|
|
4
4
|
Next steps:
|
5
5
|
1. Run "rails db:migrate"
|
6
|
-
2. Add "has_many :notifications, as: :recipient" to your User model(s).
|
6
|
+
2. Add "has_many :notifications, as: :recipient, dependent: :destroy" to your User model(s).
|
7
7
|
3. Generate notifications with "rails g noticed:notification"
|
data/lib/noticed/base.rb
CHANGED
data/lib/noticed/coder.rb
CHANGED
data/lib/noticed/model.rb
CHANGED
data/lib/noticed/version.rb
CHANGED
data/lib/noticed.rb
CHANGED
@@ -16,22 +16,13 @@ module Noticed
|
|
16
16
|
autoload :Base, "noticed/delivery_methods/base"
|
17
17
|
autoload :Database, "noticed/delivery_methods/database"
|
18
18
|
autoload :Email, "noticed/delivery_methods/email"
|
19
|
+
autoload :Fcm, "noticed/delivery_methods/fcm"
|
19
20
|
autoload :Ios, "noticed/delivery_methods/ios"
|
20
21
|
autoload :MicrosoftTeams, "noticed/delivery_methods/microsoft_teams"
|
21
22
|
autoload :Slack, "noticed/delivery_methods/slack"
|
22
23
|
autoload :Test, "noticed/delivery_methods/test"
|
23
24
|
autoload :Twilio, "noticed/delivery_methods/twilio"
|
24
25
|
autoload :Vonage, "noticed/delivery_methods/vonage"
|
25
|
-
autoload :Fcm, "noticed/delivery_methods/fcm"
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.notify(recipients:, notification:)
|
29
|
-
recipients.each do |recipient|
|
30
|
-
notification.notify(recipient)
|
31
|
-
end
|
32
|
-
|
33
|
-
# Clear the recipient after sending to the group
|
34
|
-
notification.recipient = nil
|
35
26
|
end
|
36
27
|
|
37
28
|
mattr_accessor :parent_class
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noticed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Oliver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
170
|
- !ruby/object:Gem::Version
|
171
171
|
version: '0'
|
172
172
|
requirements: []
|
173
|
-
rubygems_version: 3.3.
|
173
|
+
rubygems_version: 3.3.7
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: Notifications for Ruby on Rails applications
|