activity_notification 2.1.3 → 2.1.4
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/CHANGELOG.md +13 -1
- data/Gemfile +0 -2
- data/activity_notification.gemspec +1 -1
- data/docs/Functions.md +2 -2
- data/docs/Setup.md +176 -63
- data/gemfiles/Gemfile.rails-5.0 +1 -0
- data/gemfiles/Gemfile.rails-5.1 +1 -0
- data/gemfiles/Gemfile.rails-5.2 +1 -0
- data/gemfiles/Gemfile.rails-6.0 +0 -2
- data/lib/activity_notification/apis/notification_api.rb +7 -0
- data/lib/activity_notification/common.rb +4 -1
- data/lib/activity_notification/models/concerns/notifiable.rb +10 -10
- data/lib/activity_notification/models/concerns/swagger/notification_schema.rb +34 -34
- data/lib/activity_notification/models/concerns/swagger/subscription_schema.rb +17 -17
- data/lib/activity_notification/optional_targets/action_cable_api_channel.rb +1 -1
- data/lib/activity_notification/optional_targets/action_cable_channel.rb +1 -1
- data/lib/activity_notification/orm/dynamoid.rb +10 -3
- data/lib/activity_notification/orm/dynamoid/notification.rb +48 -13
- data/lib/activity_notification/orm/dynamoid/subscription.rb +1 -1
- data/lib/activity_notification/orm/mongoid.rb +10 -3
- data/lib/activity_notification/orm/mongoid/notification.rb +4 -4
- data/lib/activity_notification/roles/acts_as_notifiable.rb +2 -1
- data/lib/activity_notification/version.rb +1 -1
- data/spec/concerns/models/notifiable_spec.rb +35 -35
- data/spec/config_spec.rb +26 -15
- data/spec/rails_app/app/controllers/users_controller.rb +5 -0
- data/spec/rails_app/app/javascript/App.vue +8 -72
- data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +3 -4
- data/spec/rails_app/app/javascript/components/Top.vue +2 -3
- data/spec/rails_app/app/javascript/packs/spa.js +6 -3
- data/spec/rails_app/app/javascript/router/index.js +73 -0
- data/spec/rails_app/app/javascript/store/{auth.js → index.js} +0 -0
- data/spec/rails_app/app/models/dummy/dummy_group.rb +8 -0
- data/spec/rails_app/app/models/dummy/dummy_notifiable_target.rb +8 -0
- data/spec/rails_app/app/models/user.rb +2 -1
- data/spec/rails_app/config/application.rb +4 -1
- data/spec/rails_app/config/dynamoid.rb +11 -3
- data/spec/rails_app/config/environments/production.rb +3 -0
- data/spec/rails_app/config/initializers/activity_notification.rb +3 -3
- data/spec/rails_app/config/routes.rb +5 -1
- data/spec/rails_app/db/seeds.rb +9 -2
- data/spec/roles/acts_as_notifiable_spec.rb +5 -5
- metadata +6 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c77b0e25a955b70ea7753d4591e26eebaa5d8ac3ebd858fc0dbb1457a1443543
|
4
|
+
data.tar.gz: c3f39d43832aca955a9904cc9918ba247bc34b32fb5b9e2a99efdd11fb04fea5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ff3b5496a2f94cdc794c5fac124cdeb749738eb3b244f58e4622882dfbfdcddeb35518f41d7f801ad0f4c47d8695cc4c157e6d4244ae394fc2797f08f20a826
|
7
|
+
data.tar.gz: 93cf90f670ebca89d40812870f2e4ad526f5f373609a56ece0199ef50f63383204bd624a1e3af3ac65f31d431494fdac19a7c5b1bc62887fd20c961a3cb8daa2
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,16 @@
|
|
1
|
-
## 2.1.
|
1
|
+
## 2.1.4 / 2020-11-07
|
2
|
+
[Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.1.3...v2.1.4)
|
3
|
+
|
4
|
+
Enhancements:
|
5
|
+
|
6
|
+
* Make *Common#to_class_name* method return base_class name in order to work with STI models - [#89](https://github.com/simukappu/activity_notification/issues/89) [#139](https://github.com/simukappu/activity_notification/pull/139)
|
7
|
+
|
8
|
+
Bug Fixes:
|
9
|
+
|
10
|
+
* Rename *Notifiable#notification_action_cable_allowed?* to *notifiable_action_cable_allowed?* to fix duplicate method name error - [#138](https://github.com/simukappu/activity_notification/issues/138)
|
11
|
+
* Fix hash syntax in swagger schemas - [#146](https://github.com/simukappu/activity_notification/issues/146) [#147](https://github.com/simukappu/activity_notification/pull/147)
|
12
|
+
|
13
|
+
## 2.1.3 / 2020-08-11
|
2
14
|
[Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.1.2...v2.1.3)
|
3
15
|
|
4
16
|
Enhancements:
|
data/Gemfile
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.add_development_dependency 'pg', '>= 1.0.0'
|
32
32
|
s.add_development_dependency 'mongoid', '>= 4.0.0'
|
33
33
|
s.add_development_dependency 'dynamoid', '3.1.0'
|
34
|
-
s.add_development_dependency 'rspec-rails', '>= 3.8.0'
|
34
|
+
s.add_development_dependency 'rspec-rails', '>= 3.8.0'
|
35
35
|
s.add_development_dependency 'factory_bot_rails', '>= 4.11.0', '< 5.0.0'
|
36
36
|
s.add_development_dependency 'simplecov', '~> 0'
|
37
37
|
s.add_development_dependency 'yard', '>= 0.9.16'
|
data/docs/Functions.md
CHANGED
@@ -65,9 +65,9 @@ config.mailer_sender = ->(key){ key == 'inquiry.post' ? 'support@example.com' :
|
|
65
65
|
|
66
66
|
#### Email templates
|
67
67
|
|
68
|
-
*activity_notification* will look for email template in a similar way as notification views, but the view file name
|
68
|
+
*activity_notification* will look for email template in a similar way as notification views, but the view file name does not start with an underscore. For example, if you have a notification with *:key* set to *"notification.comment.reply"* and target_type *users*, the gem will look for a partial in *app/views/activity_notification/mailer/users/comment/reply.html.(|erb|haml|slim|something_else)*.
|
69
69
|
|
70
|
-
If this template is missing, the gem will
|
70
|
+
If this template is missing, the gem will use *default* as the target type which means *activity_notification/mailer/default/default.html.(|erb|haml|slim|something_else)*.
|
71
71
|
|
72
72
|
#### Email subject
|
73
73
|
|
data/docs/Setup.md
CHANGED
@@ -109,76 +109,189 @@ When **store_with_associated_records** is set to *false* as default, *activity_n
|
|
109
109
|
|
110
110
|
```json
|
111
111
|
{
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
112
|
+
"id": {
|
113
|
+
"S": "f05756ef-661e-4ef5-9e99-5af51243125c"
|
114
|
+
},
|
115
|
+
"target_key": {
|
116
|
+
"S": "User#1"
|
117
|
+
},
|
118
|
+
"notifiable_key": {
|
119
|
+
"S": "Comment#2"
|
120
|
+
},
|
121
|
+
"key": {
|
122
|
+
"S": "comment.default"
|
123
|
+
},
|
124
|
+
"group_key": {
|
125
|
+
"S": "Article#1"
|
126
|
+
},
|
127
|
+
"notifier_key": {
|
128
|
+
"S": "User#2"
|
129
|
+
},
|
130
|
+
"created_at": {
|
131
|
+
"S": "2020-03-08T08:22:53+00:00"
|
132
|
+
},
|
133
|
+
"updated_at": {
|
134
|
+
"S": "2020-03-08T08:22:53+00:00"
|
135
|
+
},
|
136
|
+
"parameters": {
|
137
|
+
"M": {}
|
138
|
+
}
|
139
139
|
}
|
140
140
|
```
|
141
141
|
|
142
|
-
When you set **store_with_associated_records** to *true*, *activity_notification* stores notificaion records including associated target, notifiable and
|
142
|
+
When you set **store_with_associated_records** to *true*, *activity_notification* stores notificaion records including associated target, notifiable, notifier and several instance methods like this:
|
143
143
|
|
144
144
|
```json
|
145
145
|
{
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
146
|
+
"id": {
|
147
|
+
"S": "f05756ef-661e-4ef5-9e99-5af51243125c"
|
148
|
+
},
|
149
|
+
"target_key": {
|
150
|
+
"S": "User#1"
|
151
|
+
},
|
152
|
+
"notifiable_key": {
|
153
|
+
"S": "Comment#2"
|
154
|
+
},
|
155
|
+
"key": {
|
156
|
+
"S": "comment.default"
|
157
|
+
},
|
158
|
+
"group_key": {
|
159
|
+
"S": "Article#1"
|
160
|
+
},
|
161
|
+
"notifier_key": {
|
162
|
+
"S": "User#2"
|
163
|
+
},
|
164
|
+
"created_at": {
|
165
|
+
"S": "2020-03-08T08:22:53+00:00"
|
166
|
+
},
|
167
|
+
"updated_at": {
|
168
|
+
"S": "2020-03-08T08:22:53+00:00"
|
169
|
+
},
|
170
|
+
"parameters": {
|
171
|
+
"M": {}
|
172
|
+
},
|
173
|
+
"stored_target": {
|
174
|
+
"M": {
|
175
|
+
"id": {
|
176
|
+
"N": "1"
|
177
|
+
},
|
178
|
+
"email": {
|
179
|
+
"S": "ichiro@example.com"
|
180
|
+
},
|
181
|
+
"name": {
|
182
|
+
"S": "Ichiro"
|
183
|
+
},
|
184
|
+
"created_at": {
|
185
|
+
"S": "2020-03-08T08:22:23.451Z"
|
186
|
+
},
|
187
|
+
"updated_at": {
|
188
|
+
"S": "2020-03-08T08:22:23.451Z"
|
189
|
+
},
|
190
|
+
// { ... },
|
191
|
+
"printable_type": {
|
192
|
+
"S": "User"
|
193
|
+
},
|
194
|
+
"printable_target_name": {
|
195
|
+
"S": "Ichiro"
|
196
|
+
},
|
197
|
+
}
|
198
|
+
},
|
199
|
+
"stored_notifiable": {
|
200
|
+
"M": {
|
201
|
+
"id": {
|
202
|
+
"N": "2"
|
203
|
+
},
|
204
|
+
"user_id": {
|
205
|
+
"N": "2"
|
206
|
+
},
|
207
|
+
"article_id": {
|
208
|
+
"N": "1"
|
209
|
+
},
|
210
|
+
"body": {
|
211
|
+
"S": "This is the first Stephen's comment to Ichiro's article."
|
212
|
+
},
|
213
|
+
"created_at": {
|
214
|
+
"S": "2020-03-08T08:22:47.683Z"
|
215
|
+
},
|
216
|
+
"updated_at": {
|
217
|
+
"S": "2020-03-08T08:22:47.683Z"
|
218
|
+
},
|
219
|
+
"printable_type": {
|
220
|
+
"S": "Comment"
|
221
|
+
}
|
222
|
+
}
|
223
|
+
},
|
224
|
+
"stored_notifier": {
|
225
|
+
"M": {
|
226
|
+
"id": {
|
227
|
+
"N": "2"
|
228
|
+
},
|
229
|
+
"email": {
|
230
|
+
"S": "stephen@example.com"
|
231
|
+
},
|
232
|
+
"name": {
|
233
|
+
"S": "Stephen"
|
234
|
+
},
|
235
|
+
"created_at": {
|
236
|
+
"S": "2020-03-08T08:22:23.573Z"
|
237
|
+
},
|
238
|
+
"updated_at": {
|
239
|
+
"S": "2020-03-08T08:22:23.573Z"
|
240
|
+
},
|
241
|
+
// { ... },
|
242
|
+
"printable_type": {
|
243
|
+
"S": "User"
|
244
|
+
},
|
245
|
+
"printable_notifier_name": {
|
246
|
+
"S": "Stephen"
|
247
|
+
}
|
248
|
+
}
|
249
|
+
},
|
250
|
+
"stored_group": {
|
251
|
+
"M": {
|
252
|
+
"id": {
|
253
|
+
"N": "1"
|
254
|
+
},
|
255
|
+
"user_id": {
|
256
|
+
"N": "1"
|
257
|
+
},
|
258
|
+
"title": {
|
259
|
+
"S": "Ichiro's first article"
|
260
|
+
},
|
261
|
+
"body": {
|
262
|
+
"S": "This is the first Ichiro's article. Please read it!"
|
263
|
+
},
|
264
|
+
"created_at": {
|
265
|
+
"S": "2020-03-08T08:22:23.952Z"
|
266
|
+
},
|
267
|
+
"updated_at": {
|
268
|
+
"S": "2020-03-08T08:22:23.952Z"
|
269
|
+
},
|
270
|
+
"printable_type": {
|
271
|
+
"S": "Article"
|
272
|
+
},
|
273
|
+
"printable_group_name": {
|
274
|
+
"S": "article \"Ichiro's first article\""
|
275
|
+
}
|
181
276
|
}
|
277
|
+
},
|
278
|
+
"stored_notifiable_path": {
|
279
|
+
"S": "/articles/1"
|
280
|
+
},
|
281
|
+
"stored_printable_notifiable_name": {
|
282
|
+
"S": "comment \"This is the first Stephen's comment to Ichiro's article.\""
|
283
|
+
},
|
284
|
+
"stored_group_member_notifier_count": {
|
285
|
+
"N": "2"
|
286
|
+
},
|
287
|
+
"stored_group_notification_count": {
|
288
|
+
"N": "3"
|
289
|
+
},
|
290
|
+
"stored_group_members": {
|
291
|
+
"L": [
|
292
|
+
// { ... }, { ... }, ...
|
293
|
+
]
|
294
|
+
}
|
182
295
|
}
|
183
296
|
```
|
184
297
|
|
data/gemfiles/Gemfile.rails-5.0
CHANGED
data/gemfiles/Gemfile.rails-5.1
CHANGED
data/gemfiles/Gemfile.rails-5.2
CHANGED
data/gemfiles/Gemfile.rails-6.0
CHANGED
@@ -495,16 +495,23 @@ module ActivityNotification
|
|
495
495
|
|
496
496
|
notification = new({ target: target, notifiable: notifiable, key: key, group: group, parameters: parameters, notifier: notifier, group_owner: group_owner })
|
497
497
|
notification.prepare_to_store.save
|
498
|
+
notification.after_store
|
498
499
|
notification
|
499
500
|
end
|
500
501
|
end
|
501
502
|
|
503
|
+
# :nocov:
|
502
504
|
# Returns prepared notification object to store
|
503
505
|
# @return [Object] prepared notification object to store
|
504
506
|
def prepare_to_store
|
505
507
|
self
|
506
508
|
end
|
507
509
|
|
510
|
+
# Call after store action with stored notification
|
511
|
+
def after_store
|
512
|
+
end
|
513
|
+
# :nocov:
|
514
|
+
|
508
515
|
# Sends notification email to the target.
|
509
516
|
#
|
510
517
|
# @param [Hash] options Options for notification email
|
@@ -98,9 +98,12 @@ module ActivityNotification
|
|
98
98
|
end
|
99
99
|
|
100
100
|
# Convets to class name.
|
101
|
+
# This function returns base_class name for STI models if the class responds to base_class method.
|
102
|
+
# @see https://github.com/simukappu/activity_notification/issues/89
|
103
|
+
# @see https://github.com/simukappu/activity_notification/pull/139
|
101
104
|
# @return [String] Class name
|
102
105
|
def to_class_name
|
103
|
-
self.class.name
|
106
|
+
self.class.respond_to?(:base_class) ? self.class.base_class.name : self.class.name
|
104
107
|
end
|
105
108
|
|
106
109
|
# Convets to singularized model name (resource name).
|
@@ -25,8 +25,8 @@ module ActivityNotification
|
|
25
25
|
:_notifier,
|
26
26
|
:_notification_parameters,
|
27
27
|
:_notification_email_allowed,
|
28
|
-
:
|
29
|
-
:
|
28
|
+
:_notifiable_action_cable_allowed,
|
29
|
+
:_notifiable_action_cable_api_allowed,
|
30
30
|
:_notifiable_path,
|
31
31
|
:_printable_notifiable_name,
|
32
32
|
:_optional_targets
|
@@ -55,8 +55,8 @@ module ActivityNotification
|
|
55
55
|
self._notifier = {}
|
56
56
|
self._notification_parameters = {}
|
57
57
|
self._notification_email_allowed = {}
|
58
|
-
self.
|
59
|
-
self.
|
58
|
+
self._notifiable_action_cable_allowed = {}
|
59
|
+
self._notifiable_action_cable_api_allowed = {}
|
60
60
|
self._notifiable_path = {}
|
61
61
|
self._printable_notifiable_name = {}
|
62
62
|
self._optional_targets = {}
|
@@ -162,10 +162,10 @@ module ActivityNotification
|
|
162
162
|
# @param [Object] target Target instance to notify
|
163
163
|
# @param [String] key Key of the notification
|
164
164
|
# @return [Boolean] If publishing WebSocket using ActionCable is allowed for the notifiable
|
165
|
-
def
|
165
|
+
def notifiable_action_cable_allowed?(target, key = nil)
|
166
166
|
resolve_parameter(
|
167
|
-
"
|
168
|
-
|
167
|
+
"notifiable_action_cable_allowed_for_#{cast_to_resources_name(target.class)}?",
|
168
|
+
_notifiable_action_cable_allowed[cast_to_resources_sym(target.class)],
|
169
169
|
ActivityNotification.config.action_cable_enabled,
|
170
170
|
target, key)
|
171
171
|
end
|
@@ -176,10 +176,10 @@ module ActivityNotification
|
|
176
176
|
# @param [Object] target Target instance to notify
|
177
177
|
# @param [String] key Key of the notification
|
178
178
|
# @return [Boolean] If publishing WebSocket API using ActionCable is allowed for the notifiable
|
179
|
-
def
|
179
|
+
def notifiable_action_cable_api_allowed?(target, key = nil)
|
180
180
|
resolve_parameter(
|
181
|
-
"
|
182
|
-
|
181
|
+
"notifiable_action_cable_api_allowed_for_#{cast_to_resources_name(target.class)}?",
|
182
|
+
_notifiable_action_cable_api_allowed[cast_to_resources_sym(target.class)],
|
183
183
|
ActivityNotification.config.action_cable_api_enabled,
|
184
184
|
target, key)
|
185
185
|
end
|
@@ -90,7 +90,7 @@ module ActivityNotification
|
|
90
90
|
type: :string
|
91
91
|
}
|
92
92
|
key :example, {
|
93
|
-
|
93
|
+
test_default_param: "1"
|
94
94
|
}
|
95
95
|
end
|
96
96
|
property :opened_at do
|
@@ -139,28 +139,28 @@ module ActivityNotification
|
|
139
139
|
key :type, :object
|
140
140
|
key :description, "Associated target model in your application"
|
141
141
|
key :example, {
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
142
|
+
id: 1,
|
143
|
+
email: "ichiro@example.com",
|
144
|
+
name: "Ichiro",
|
145
|
+
created_at: Time.current,
|
146
|
+
updated_at: Time.current,
|
147
|
+
provider: "email",
|
148
|
+
uid: "",
|
149
|
+
printable_type: "User",
|
150
|
+
printable_target_name: "Ichiro"
|
151
151
|
}
|
152
152
|
end
|
153
153
|
property :notifiable do
|
154
154
|
key :type, :object
|
155
155
|
key :description, "Associated notifiable model in your application"
|
156
156
|
key :example, {
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
157
|
+
id: 22,
|
158
|
+
user_id: 2,
|
159
|
+
article_id: 11,
|
160
|
+
body: "This is the first Stephen's comment to Ichiro's article.",
|
161
|
+
created_at: Time.current,
|
162
|
+
updated_at: Time.current,
|
163
|
+
printable_type: "Comment"
|
164
164
|
}
|
165
165
|
end
|
166
166
|
property :group do
|
@@ -168,14 +168,14 @@ module ActivityNotification
|
|
168
168
|
key :description, "Associated group model in your application"
|
169
169
|
key :nullable, true
|
170
170
|
key :example, {
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
171
|
+
id: 11,
|
172
|
+
user_id: 4,
|
173
|
+
title: "Ichiro's great article",
|
174
|
+
body: "This is Ichiro's great article. Please read it!",
|
175
|
+
created_at: Time.current,
|
176
|
+
updated_at: Time.current,
|
177
|
+
printable_type: "Article",
|
178
|
+
printable_group_name: "article \"Ichiro's great article\""
|
179
179
|
}
|
180
180
|
end
|
181
181
|
property :notifier do
|
@@ -183,15 +183,15 @@ module ActivityNotification
|
|
183
183
|
key :description, "Associated notifier model in your application"
|
184
184
|
key :nullable, true
|
185
185
|
key :example, {
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
186
|
+
id: 2,
|
187
|
+
email: "stephen@example.com",
|
188
|
+
name: "Stephen",
|
189
|
+
created_at: Time.current,
|
190
|
+
updated_at: Time.current,
|
191
|
+
provider: "email",
|
192
|
+
uid: "",
|
193
|
+
printable_type: "User",
|
194
|
+
printable_notifier_name: "Stephen"
|
195
195
|
}
|
196
196
|
end
|
197
197
|
property :group_members do
|