notification-settings 1.2.6 → 2.0.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 +128 -83
- data/app/models/notification_settings/subscription.rb +1 -2
- data/lib/generators/notification_settings/install_generator.rb +2 -1
- data/lib/generators/templates/install/initializer.rb +18 -6
- data/lib/generators/templates/install/notifications_migration.rb.erb +11 -13
- data/lib/notification-settings.rb +10 -5
- data/lib/notification_settings/category_preferences_form.rb +13 -0
- data/lib/notification_settings/configuration.rb +15 -7
- data/lib/notification_settings/delivery_method_preferences_form.rb +15 -0
- data/lib/notification_settings/engine.rb +1 -1
- data/lib/notification_settings/notification_lib.rb +168 -0
- data/lib/notification_settings/notification_scopes.rb +1 -5
- data/lib/notification_settings/preferences_form.rb +11 -0
- data/lib/notification_settings/settings.rb +28 -0
- data/lib/notification_settings/{setting_library.rb → status.rb} +15 -11
- data/lib/notification_settings/subscribable.rb +10 -12
- data/lib/notification_settings/subscriber.rb +6 -7
- data/lib/notification_settings/target.rb +2 -15
- metadata +106 -21
- data/app/models/notification_settings/setting.rb +0 -15
- data/lib/notification_settings/notification_library.rb +0 -144
- data/lib/notification_settings/subscription_library.rb +0 -23
@@ -7,21 +7,8 @@ module NotificationSettings
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
included do
|
10
|
-
|
11
|
-
|
12
|
-
class_name: 'NotificationSettings::Setting',
|
13
|
-
dependent: :destroy
|
14
|
-
before_create :create_notification_setting
|
15
|
-
|
16
|
-
include NotificationSettings::Target::InstanceMethods
|
17
|
-
end
|
18
|
-
|
19
|
-
module InstanceMethods
|
20
|
-
private
|
21
|
-
|
22
|
-
def create_notification_setting
|
23
|
-
build_notification_setting
|
24
|
-
end
|
10
|
+
include NotificationSettings::Settings
|
11
|
+
include NotificationSettings::Status
|
25
12
|
end
|
26
13
|
end
|
27
14
|
end
|
metadata
CHANGED
@@ -1,73 +1,143 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notification-settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Hübotter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: activerecord
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- - "
|
31
|
+
- - ">="
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
33
|
+
version: '5.0'
|
20
34
|
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- - "
|
38
|
+
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
40
|
+
version: '5.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hashie
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
30
58
|
requirements:
|
31
59
|
- - "~>"
|
32
60
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
61
|
+
version: '3.6'
|
34
62
|
type: :runtime
|
35
63
|
prerelease: false
|
36
64
|
version_requirements: !ruby/object:Gem::Requirement
|
37
65
|
requirements:
|
38
66
|
- - "~>"
|
39
67
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
68
|
+
version: '3.6'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: notification-handler
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
73
|
- - '='
|
46
74
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
75
|
+
version: 2.0.0
|
48
76
|
type: :runtime
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
52
80
|
- - '='
|
53
81
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
82
|
+
version: 2.0.0
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: railties
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
|
-
- - "
|
87
|
+
- - ">="
|
60
88
|
- !ruby/object:Gem::Version
|
61
|
-
version: '5.
|
89
|
+
version: '5.0'
|
62
90
|
type: :runtime
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
|
-
- - "
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '5.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: factory_bot
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
67
109
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
110
|
+
version: '0'
|
69
111
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rails
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec-rails
|
71
141
|
requirement: !ruby/object:Gem::Requirement
|
72
142
|
requirements:
|
73
143
|
- - ">="
|
@@ -108,6 +178,20 @@ dependencies:
|
|
108
178
|
- - ">="
|
109
179
|
- !ruby/object:Gem::Version
|
110
180
|
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: sqlite3
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
111
195
|
description: Integrates with your authentication solution to craft a personalized
|
112
196
|
user notification platform.
|
113
197
|
email: me@jonhue.me
|
@@ -117,20 +201,22 @@ extra_rdoc_files: []
|
|
117
201
|
files:
|
118
202
|
- LICENSE
|
119
203
|
- README.md
|
120
|
-
- app/models/notification_settings/setting.rb
|
121
204
|
- app/models/notification_settings/subscription.rb
|
122
205
|
- lib/generators/notification_settings/install_generator.rb
|
123
206
|
- lib/generators/templates/install/initializer.rb
|
124
207
|
- lib/generators/templates/install/notifications_migration.rb.erb
|
125
208
|
- lib/notification-settings.rb
|
209
|
+
- lib/notification_settings/category_preferences_form.rb
|
126
210
|
- lib/notification_settings/configuration.rb
|
211
|
+
- lib/notification_settings/delivery_method_preferences_form.rb
|
127
212
|
- lib/notification_settings/engine.rb
|
128
|
-
- lib/notification_settings/
|
213
|
+
- lib/notification_settings/notification_lib.rb
|
129
214
|
- lib/notification_settings/notification_scopes.rb
|
130
|
-
- lib/notification_settings/
|
215
|
+
- lib/notification_settings/preferences_form.rb
|
216
|
+
- lib/notification_settings/settings.rb
|
217
|
+
- lib/notification_settings/status.rb
|
131
218
|
- lib/notification_settings/subscribable.rb
|
132
219
|
- lib/notification_settings/subscriber.rb
|
133
|
-
- lib/notification_settings/subscription_library.rb
|
134
220
|
- lib/notification_settings/target.rb
|
135
221
|
homepage: https://github.com/jonhue/notifications-rails/tree/master/notification-settings
|
136
222
|
licenses:
|
@@ -151,8 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
237
|
- !ruby/object:Gem::Version
|
152
238
|
version: '0'
|
153
239
|
requirements: []
|
154
|
-
|
155
|
-
rubygems_version: 2.7.6
|
240
|
+
rubygems_version: 3.0.3
|
156
241
|
signing_key:
|
157
242
|
specification_version: 4
|
158
243
|
summary: Integrates with your authentication solution to craft a personalized user
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module NotificationSettings
|
4
|
-
class Setting < ActiveRecord::Base
|
5
|
-
self.table_name = 'notification_settings_settings'
|
6
|
-
|
7
|
-
include NotificationSettings::SettingLibrary
|
8
|
-
|
9
|
-
serialize :settings, Hash
|
10
|
-
serialize :category_settings, Hash
|
11
|
-
|
12
|
-
belongs_to :object, polymorphic: true, optional: true
|
13
|
-
belongs_to :subscription, optional: true
|
14
|
-
end
|
15
|
-
end
|
@@ -1,144 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'notification-handler'
|
4
|
-
require 'active_support'
|
5
|
-
|
6
|
-
module NotificationSettings
|
7
|
-
module NotificationLibrary
|
8
|
-
extend ActiveSupport::Concern
|
9
|
-
|
10
|
-
included do
|
11
|
-
before_create :validate_create
|
12
|
-
|
13
|
-
belongs_to :subscription,
|
14
|
-
class_name: 'NotificationSettings::Subscription',
|
15
|
-
optional: true
|
16
|
-
|
17
|
-
include NotificationSettings::NotificationLibrary::InstanceMethods
|
18
|
-
end
|
19
|
-
|
20
|
-
module InstanceMethods
|
21
|
-
def category
|
22
|
-
self[:category] || NotificationSettings.configuration.default_category
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def validate_create
|
28
|
-
throw(:abort) unless can_create?
|
29
|
-
end
|
30
|
-
|
31
|
-
def can_create?
|
32
|
-
if target.notification_setting.present?
|
33
|
-
unless status_allows_create? &&
|
34
|
-
settings_allow_create? &&
|
35
|
-
category_settings_allow_create?
|
36
|
-
return false
|
37
|
-
end
|
38
|
-
end
|
39
|
-
true
|
40
|
-
end
|
41
|
-
|
42
|
-
def status_allows_create?
|
43
|
-
!do_not_notify_statuses.include?(target.notification_setting.status)
|
44
|
-
end
|
45
|
-
|
46
|
-
def settings_allow_create?
|
47
|
-
target.notification_setting.settings.dig(:enabled)
|
48
|
-
end
|
49
|
-
|
50
|
-
def category_settings_allow_create?
|
51
|
-
target.notification_setting.category_settings.dig(
|
52
|
-
category.to_sym,
|
53
|
-
:enabled
|
54
|
-
)
|
55
|
-
end
|
56
|
-
|
57
|
-
def initialize_pusher
|
58
|
-
return unless can_push?
|
59
|
-
super
|
60
|
-
end
|
61
|
-
|
62
|
-
def can_push?
|
63
|
-
if target.notification_setting.present?
|
64
|
-
return false unless status_allows_push?
|
65
|
-
|
66
|
-
if push.is_a?(Array)
|
67
|
-
return false unless can_use_pushers?(push)
|
68
|
-
else
|
69
|
-
return false unless can_use_pusher?(push)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
true
|
73
|
-
end
|
74
|
-
|
75
|
-
def can_use_pushers?(pushers)
|
76
|
-
pushers.each do |pusher|
|
77
|
-
return false unless can_use_pusher?(pusher)
|
78
|
-
end
|
79
|
-
true
|
80
|
-
end
|
81
|
-
|
82
|
-
def can_use_pusher?(pusher)
|
83
|
-
unless settings_allow_push?(pusher) &&
|
84
|
-
category_settings_allow_push?(pusher)
|
85
|
-
return false
|
86
|
-
end
|
87
|
-
true
|
88
|
-
end
|
89
|
-
|
90
|
-
def status_allows_push?
|
91
|
-
!do_not_push_statuses.include?(target.notification_setting.status)
|
92
|
-
end
|
93
|
-
|
94
|
-
def settings_allow_push?(pusher)
|
95
|
-
return global_settings_allow_push? unless local_pusher_settings?(pusher)
|
96
|
-
local_settings_allow_push?(pusher)
|
97
|
-
end
|
98
|
-
|
99
|
-
def local_pusher_settings?(pusher)
|
100
|
-
local_settings_allow_push?(pusher).present?
|
101
|
-
end
|
102
|
-
|
103
|
-
def local_settings_allow_push?(pusher)
|
104
|
-
target.notification_setting.settings.dig(pusher.to_sym)
|
105
|
-
end
|
106
|
-
|
107
|
-
def global_settings_allow_push?
|
108
|
-
target.notification_setting.settings.dig(:index)
|
109
|
-
end
|
110
|
-
|
111
|
-
def category_settings_allow_push?(pusher)
|
112
|
-
if local_pusher_category_settings?(pusher)
|
113
|
-
local_category_settings_allow_push?(pusher)
|
114
|
-
else
|
115
|
-
global_category_settings_allow_push?
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def local_pusher_category_settings?(pusher)
|
120
|
-
local_category_settings_allow_push?(pusher).present?
|
121
|
-
end
|
122
|
-
|
123
|
-
def local_category_settings_allow_push?(pusher)
|
124
|
-
target.notification_setting.category_settings.dig(
|
125
|
-
category.to_sym, pusher.to_sym
|
126
|
-
)
|
127
|
-
end
|
128
|
-
|
129
|
-
def global_category_settings_allow_push?
|
130
|
-
target.notification_setting.category_settings.dig(
|
131
|
-
category.to_sym, :index
|
132
|
-
)
|
133
|
-
end
|
134
|
-
|
135
|
-
def do_not_notify_statuses
|
136
|
-
NotificationSettings.configuration.do_not_notify_statuses
|
137
|
-
end
|
138
|
-
|
139
|
-
def do_not_push_statuses
|
140
|
-
NotificationSettings.configuration.do_not_push_statuses
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_support'
|
4
|
-
|
5
|
-
module NotificationSettings
|
6
|
-
module SubscriptionLibrary
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
included do
|
10
|
-
after_create_commit :create_notification_setting
|
11
|
-
|
12
|
-
include NotificationSettings::SubscriptionLibrary::InstanceMethods
|
13
|
-
end
|
14
|
-
|
15
|
-
module InstanceMethods
|
16
|
-
private
|
17
|
-
|
18
|
-
def create_notification_setting
|
19
|
-
notification_setting.create!
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|