notification-handler 1.0.0.beta8 → 1.0.0.beta9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/templates/install/notification_model.rb +5 -1
- data/lib/notification-handler.rb +0 -2
- data/lib/notification_handler/configuration.rb +1 -1
- data/lib/notification_handler/notification_library.rb +42 -24
- data/lib/notification_handler/notification_scopes.rb +9 -2
- data/lib/notification_handler/target.rb +1 -2
- metadata +1 -2
- data/lib/notification_handler/engine.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fe2fe2c91eabaaec753df7ba65e183a7050eea1270f45c5a3066e535e0ae1b3
|
4
|
+
data.tar.gz: dd8f5a2801afa7cc2b8e9d2f372398151c94f6c4139210bf846a63beea89944e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed9de05b283ff004cd5b3dda16287cfc4e516a44d65457146025b93c92b4d1993791a45c92f138133e77f4c436e19d5f73eb52af23c948b3b140726998f9679d
|
7
|
+
data.tar.gz: 69cbc0114a5b412ef7eec404829080deb34999eda805ac0ea8fab5a8450aad31145e167ae6aa0a5dfa1396ec297ef898e459704cbb663ea184a9b523475d3611
|
data/lib/notification-handler.rb
CHANGED
@@ -1,39 +1,57 @@
|
|
1
1
|
module NotificationHandler
|
2
2
|
module NotificationLibrary
|
3
3
|
|
4
|
-
|
4
|
+
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
included do
|
7
|
+
before_validation :create_for_group
|
8
|
+
after_commit :cache
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
serialize :metadata, Hash
|
11
|
+
attr_accessor :group
|
12
|
+
|
13
|
+
belongs_to :target, polymorphic: true
|
14
|
+
belongs_to :object, polymorphic: true, optional: true
|
15
|
+
|
16
|
+
include NotificationHandler::NotificationLibrary::InstanceMethods
|
17
|
+
|
18
|
+
include NotificationRenderer::NotificationLibrary if defined?(NotificationRenderer)
|
19
|
+
include NotificationPusher::NotificationLibrary if defined?(NotificationPusher)
|
20
|
+
include NotificationSettings::NotificationLibrary if defined?(NotificationSettings)
|
14
21
|
end
|
15
22
|
|
16
|
-
|
23
|
+
module InstanceMethods
|
17
24
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
def read?
|
26
|
+
self.read
|
27
|
+
end
|
28
|
+
def unread?
|
29
|
+
!self.read
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def create_for_group
|
35
|
+
unless self.group.nil?
|
36
|
+
target_scope = NotificationHandler::Group.find_by_name(self.group).last.target_scope
|
37
|
+
target_scope&.each do |target|
|
38
|
+
notification = self.dup
|
39
|
+
notification.target = target
|
40
|
+
notification.group = nil
|
41
|
+
notification.save
|
42
|
+
end
|
43
|
+
return false
|
26
44
|
end
|
27
|
-
return false
|
28
45
|
end
|
29
|
-
end
|
30
46
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
47
|
+
def cache
|
48
|
+
if self.read_changed?
|
49
|
+
self.target.read_notification_count = self.target.notifications.read.count
|
50
|
+
self.target.unread_notification_count = self.target.notifications.unread.count
|
51
|
+
self.target.save!
|
52
|
+
end
|
36
53
|
end
|
54
|
+
|
37
55
|
end
|
38
56
|
|
39
57
|
end
|
@@ -1,8 +1,15 @@
|
|
1
1
|
module NotificationHandler
|
2
2
|
module NotificationScopes
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
scope :read, -> { where(read: true) }
|
8
|
+
scope :unread, -> { where(read: false) }
|
9
|
+
|
10
|
+
include NotificationRenderer::NotificationScopes if defined?(NotificationRenderer)
|
11
|
+
include NotificationSettings::NotificationScopes if defined?(NotificationSettings)
|
12
|
+
end
|
6
13
|
|
7
14
|
end
|
8
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notification-handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Hübotter
|
@@ -82,7 +82,6 @@ files:
|
|
82
82
|
- lib/generators/templates/install/notifications_migration.rb.erb
|
83
83
|
- lib/notification-handler.rb
|
84
84
|
- lib/notification_handler/configuration.rb
|
85
|
-
- lib/notification_handler/engine.rb
|
86
85
|
- lib/notification_handler/group.rb
|
87
86
|
- lib/notification_handler/notification_library.rb
|
88
87
|
- lib/notification_handler/notification_scopes.rb
|