noticed 2.0.1 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/channels/noticed/notification_channel.rb +19 -0
- data/lib/generators/noticed/notifier_generator.rb +9 -1
- data/lib/generators/noticed/templates/notifier.rb.tt +1 -1
- data/lib/noticed/delivery_method.rb +1 -1
- data/lib/noticed/delivery_methods/action_cable.rb +3 -3
- data/lib/noticed/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf12a81661e3c6fa7e6240e54f6cb802420b13e2cfd35feabdc713a415986b5a
|
4
|
+
data.tar.gz: '08074571747ce14478e7f45de5917700fa997caefd0bb93b3bd154287f3b7830'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5ed4a60a134a094a9837127d2ac5aaab7ab2bae500222861ebb99e3053ef8450a439093543f03f58fefe5d1df04b47e519bfcfb3193b2aa82262bb5d725fe7a
|
7
|
+
data.tar.gz: 4cfcb122083862b7400459b99695619fabafb8676ea44e5185a06f85eaa693cc12a4eca0fb3094a0c502017fe0b67767d5853ec72e5928b4b560209189e95c4e
|
data/README.md
CHANGED
@@ -87,7 +87,7 @@ class NewCommentNotifier < Noticed::Event
|
|
87
87
|
|
88
88
|
deliver_by :email do |config|
|
89
89
|
config.mailer = "CommentMailer"
|
90
|
-
|
90
|
+
config.if = ->(recipient) { !!recipient.preferences[:email] }
|
91
91
|
end
|
92
92
|
|
93
93
|
bulk_deliver_by :discord do |config|
|
@@ -201,7 +201,7 @@ en:
|
|
201
201
|
notifiers:
|
202
202
|
new_comment_notifier:
|
203
203
|
notification:
|
204
|
-
|
204
|
+
message: "Someone posted a new comment!"
|
205
205
|
```
|
206
206
|
|
207
207
|
Or, if you have your Notifier within another module, such as `Admin::NewCommentNotifier`, the resulting lookup path will be `en.notifiers.admin.new_comment_notifier.notification.message` (modules become nesting steps).
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Noticed
|
2
|
+
class NotificationChannel < ApplicationCable::Channel
|
3
|
+
def subscribed
|
4
|
+
stream_for current_user
|
5
|
+
end
|
6
|
+
|
7
|
+
def unsubscribed
|
8
|
+
stop_all_streams
|
9
|
+
end
|
10
|
+
|
11
|
+
def mark_as_seen(data)
|
12
|
+
current_user.notifications.where(id: data["ids"]).mark_as_seen
|
13
|
+
end
|
14
|
+
|
15
|
+
def mark_as_read(data)
|
16
|
+
current_user.notifications.where(id: data["ids"]).mark_as_read
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -7,12 +7,20 @@ module Noticed
|
|
7
7
|
class NotifierGenerator < Rails::Generators::NamedBase
|
8
8
|
include Rails::Generators::ResourceHelpers
|
9
9
|
|
10
|
+
check_class_collision suffix: "Notifier"
|
11
|
+
|
10
12
|
source_root File.expand_path("../templates", __FILE__)
|
11
13
|
|
12
14
|
desc "Generates a notification with the given NAME."
|
13
15
|
|
14
16
|
def generate_notification
|
15
|
-
template "notifier.rb", "app/notifiers/#{file_path}.rb"
|
17
|
+
template "notifier.rb", "app/notifiers/#{file_path}_notifier.rb"
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def file_name # :doc:
|
23
|
+
@_file_name ||= super.sub(/_notifier\z/i, "")
|
16
24
|
end
|
17
25
|
end
|
18
26
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Noticed
|
2
2
|
module DeliveryMethods
|
3
3
|
class ActionCable < DeliveryMethod
|
4
|
-
required_options :
|
4
|
+
required_options :message
|
5
5
|
|
6
6
|
def deliver
|
7
|
-
channel = fetch_constant(:channel)
|
8
|
-
stream = evaluate_option(:stream)
|
7
|
+
channel = fetch_constant(:channel) || Noticed::NotificationChannel
|
8
|
+
stream = evaluate_option(:stream) || recipient
|
9
9
|
message = evaluate_option(:message)
|
10
10
|
|
11
11
|
channel.broadcast_to stream, message
|
data/lib/noticed/version.rb
CHANGED
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: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Oliver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- MIT-LICENSE
|
36
36
|
- README.md
|
37
37
|
- Rakefile
|
38
|
+
- app/channels/noticed/notification_channel.rb
|
38
39
|
- app/jobs/noticed/application_job.rb
|
39
40
|
- app/jobs/noticed/event_job.rb
|
40
41
|
- app/models/concerns/noticed/deliverable.rb
|