noticed 2.7.0 → 2.8.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 +30 -2
- data/app/models/concerns/noticed/deliverable.rb +2 -2
- data/lib/generators/noticed/delivery_method_generator.rb +9 -2
- data/lib/generators/noticed/templates/application_bulk_delivery_method.rb.tt +2 -0
- data/lib/generators/noticed/templates/bulk_delivery_method.rb.tt +14 -0
- data/lib/generators/noticed/templates/delivery_method.rb.tt +6 -0
- data/lib/generators/noticed/templates/notifier.rb.tt +6 -0
- data/lib/noticed/delivery_methods/fcm.rb +2 -0
- data/lib/noticed/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dec070db3dc9527a542e8f4cb57edc6dd61397c8cb870dd3efbb4dccd905b410
|
4
|
+
data.tar.gz: 9ca50907997ea442ff27c305d679aa7ed4e02d80658938bc7f5b75e4888ce95d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9539c8bc4303864682d8270eebb39b0e1e79b0db7e50b8674e0cdae9c5bb1ec59b5ae556309162e91c74e678bcfb37369414edbeeaebb081a1822395de79e561
|
7
|
+
data.tar.gz: 67190713e1fefee0a28458659e04dd5a4d3984b620e7ccb080e1e6e5dc6d49ec06b63d6c74ae8ab1a6b4dda99e1a2dc4bfb43a0495b9271015e45762c378ad21
|
data/README.md
CHANGED
@@ -493,6 +493,27 @@ module MyApp
|
|
493
493
|
end
|
494
494
|
```
|
495
495
|
|
496
|
+
#### Tip: Custom properties on a notification per recipient
|
497
|
+
|
498
|
+
In order to have recipient-specific settings on the notification, override the `recipient_attributes_for(recipient)` method in your notifier:
|
499
|
+
|
500
|
+
```ruby
|
501
|
+
class CommentNotifier < ApplicationNotifier
|
502
|
+
#...
|
503
|
+
def recipient_attributes_for(recipient)
|
504
|
+
data = super
|
505
|
+
data[:priority] = if recipient.participant?
|
506
|
+
"high"
|
507
|
+
else
|
508
|
+
"low"
|
509
|
+
end
|
510
|
+
data
|
511
|
+
end
|
512
|
+
end
|
513
|
+
```
|
514
|
+
|
515
|
+
Assuming you have a `priority` column in the `noticed_notifications` table, it will be set to the value from the hash here. The default properties of the hash are `recipient_type` and `recipient_id`.
|
516
|
+
|
496
517
|
## ✅ Best Practices
|
497
518
|
|
498
519
|
### Renaming Notifiers
|
@@ -573,7 +594,9 @@ You can mix and match the options and delivery methods to suit your application
|
|
573
594
|
|
574
595
|
If you want to build your own delivery method to deliver notifications to a specific service or medium that Noticed doesn’t (or doesn’t _yet_) support, you’re welcome to do so! To generate a custom delivery method, simply run
|
575
596
|
|
576
|
-
|
597
|
+
```bash
|
598
|
+
rails generate noticed:delivery_method Discord
|
599
|
+
```
|
577
600
|
|
578
601
|
This will generate a new `ApplicationDeliveryMethod` and `DeliveryMethods::Discord` class inside the `app/notifiers/delivery_methods` folder, which can be used to deliver notifications to Discord.
|
579
602
|
|
@@ -586,7 +609,6 @@ class DeliveryMethods::Discord < ApplicationDeliveryMethod
|
|
586
609
|
# Logic for sending the notification
|
587
610
|
end
|
588
611
|
end
|
589
|
-
|
590
612
|
```
|
591
613
|
|
592
614
|
You can use the custom delivery method thus created by adding a `deliver_by` line with a unique name and `class` option in your notification class.
|
@@ -597,6 +619,12 @@ class MyNotifier < Noticed::Event
|
|
597
619
|
end
|
598
620
|
```
|
599
621
|
|
622
|
+
You can also generate bulk delivery methods with the `--bulk` flag:
|
623
|
+
|
624
|
+
```bash
|
625
|
+
rails generate noticed:delivery_method Discord --bulk
|
626
|
+
```
|
627
|
+
|
600
628
|
<details>
|
601
629
|
<summary>Turbo Stream Custom Delivery Method Example</summary>
|
602
630
|
|
@@ -118,9 +118,9 @@ module Noticed
|
|
118
118
|
def evaluate_recipients
|
119
119
|
return unless _recipients
|
120
120
|
|
121
|
-
if _recipients.respond_to?(:call)
|
121
|
+
if _recipients.respond_to?(:call, true)
|
122
122
|
instance_exec(&_recipients)
|
123
|
-
elsif _recipients.is_a?(Symbol) && respond_to?(_recipients)
|
123
|
+
elsif _recipients.is_a?(Symbol) && respond_to?(_recipients, true)
|
124
124
|
send(_recipients)
|
125
125
|
end
|
126
126
|
end
|
@@ -11,9 +11,16 @@ module Noticed
|
|
11
11
|
|
12
12
|
desc "Generates a class for a custom delivery method with the given NAME."
|
13
13
|
|
14
|
+
class_option :bulk, desc: "Generate as a bulk delivery method", type: :boolean, default: false
|
15
|
+
|
14
16
|
def generate_notification
|
15
|
-
|
16
|
-
|
17
|
+
if options[:bulk]
|
18
|
+
template "application_bulk_delivery_method.rb", "app/notifiers/application_bulk_delivery_method.rb"
|
19
|
+
template "bulk_delivery_method.rb", "app/notifiers/bulk_delivery_methods/#{singular_name}.rb"
|
20
|
+
else
|
21
|
+
template "application_delivery_method.rb", "app/notifiers/application_delivery_method.rb"
|
22
|
+
template "delivery_method.rb", "app/notifiers/delivery_methods/#{singular_name}.rb"
|
23
|
+
end
|
17
24
|
end
|
18
25
|
end
|
19
26
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class BulkDeliveryMethods::<%= class_name %> < ApplicationBulkDeliveryMethod
|
2
|
+
# To use this delivery method, specify the class option in your notifier.
|
3
|
+
#
|
4
|
+
# class MyNotifer < ApplicationNotifier
|
5
|
+
# bulk_deliver_by :<%= file_path %>, class: "<%= class_name %>"
|
6
|
+
# end
|
7
|
+
|
8
|
+
# Specify the config options your delivery method requires in its config block
|
9
|
+
required_options # :foo, :bar
|
10
|
+
|
11
|
+
def deliver
|
12
|
+
# Logic for sending the notification
|
13
|
+
end
|
14
|
+
end
|
@@ -1,4 +1,10 @@
|
|
1
1
|
class DeliveryMethods::<%= class_name %> < ApplicationDeliveryMethod
|
2
|
+
# To use this delivery method, specify the class option in your notifier.
|
3
|
+
#
|
4
|
+
# class MyNotifer < ApplicationNotifier
|
5
|
+
# deliver_by :<%= file_path %>, class: "<%= class_name %>"
|
6
|
+
# end
|
7
|
+
|
2
8
|
# Specify the config options your delivery method requires in its config block
|
3
9
|
required_options # :foo, :bar
|
4
10
|
|
@@ -18,6 +18,8 @@ module Noticed
|
|
18
18
|
rescue Noticed::ResponseUnsuccessful => exception
|
19
19
|
if bad_token?(exception.response) && config[:invalid_token]
|
20
20
|
notification.instance_exec(device_token, &config[:invalid_token])
|
21
|
+
elsif config[:error_handler]
|
22
|
+
notification.instance_exec(exception.response, &config[:error_handler])
|
21
23
|
else
|
22
24
|
raise
|
23
25
|
end
|
data/lib/noticed/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noticed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Oliver
|
@@ -50,8 +50,10 @@ files:
|
|
50
50
|
- lib/generators/noticed/install_generator.rb
|
51
51
|
- lib/generators/noticed/notifier_generator.rb
|
52
52
|
- lib/generators/noticed/templates/README
|
53
|
+
- lib/generators/noticed/templates/application_bulk_delivery_method.rb.tt
|
53
54
|
- lib/generators/noticed/templates/application_delivery_method.rb.tt
|
54
55
|
- lib/generators/noticed/templates/application_notifier.rb.tt
|
56
|
+
- lib/generators/noticed/templates/bulk_delivery_method.rb.tt
|
55
57
|
- lib/generators/noticed/templates/delivery_method.rb.tt
|
56
58
|
- lib/generators/noticed/templates/notifier.rb.tt
|
57
59
|
- lib/noticed.rb
|
@@ -99,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
101
|
- !ruby/object:Gem::Version
|
100
102
|
version: '0'
|
101
103
|
requirements: []
|
102
|
-
rubygems_version: 3.
|
104
|
+
rubygems_version: 3.7.0
|
103
105
|
specification_version: 4
|
104
106
|
summary: Notifications for Ruby on Rails applications
|
105
107
|
test_files: []
|