activity_notification 2.1.1 → 2.2.1
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/.travis.yml +10 -16
- data/CHANGELOG.md +53 -0
- data/Gemfile +2 -3
- data/README.md +1 -1
- data/activity_notification.gemspec +1 -1
- data/app/channels/activity_notification/notification_api_with_devise_channel.rb +1 -1
- data/app/channels/activity_notification/notification_channel.rb +1 -1
- data/app/channels/activity_notification/notification_with_devise_channel.rb +1 -1
- data/app/controllers/activity_notification/notifications_api_with_devise_controller.rb +1 -1
- data/app/controllers/activity_notification/notifications_controller.rb +0 -20
- data/app/controllers/activity_notification/subscriptions_api_controller.rb +1 -1
- data/app/controllers/activity_notification/subscriptions_api_with_devise_controller.rb +1 -1
- data/bin/bundle_update.sh +0 -1
- data/docs/Functions.md +2 -2
- data/docs/Setup.md +190 -63
- data/gemfiles/Gemfile.rails-5.0 +3 -1
- data/gemfiles/Gemfile.rails-5.1 +3 -1
- data/gemfiles/Gemfile.rails-5.2 +3 -1
- data/gemfiles/Gemfile.rails-6.0 +2 -3
- data/gemfiles/Gemfile.rails-6.1 +24 -0
- data/lib/activity_notification/apis/notification_api.rb +7 -0
- data/lib/activity_notification/common.rb +15 -4
- data/lib/activity_notification/controllers/common_controller.rb +2 -18
- data/lib/activity_notification/models/concerns/notifiable.rb +12 -12
- 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/models/concerns/target.rb +5 -9
- 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/active_record.rb +1 -1
- data/lib/activity_notification/orm/active_record/notification.rb +3 -3
- data/lib/activity_notification/orm/dynamoid.rb +10 -3
- data/lib/activity_notification/orm/dynamoid/notification.rb +49 -14
- 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 +8 -6
- data/lib/activity_notification/orm/mongoid/subscription.rb +1 -1
- data/lib/activity_notification/renderable.rb +2 -2
- data/lib/activity_notification/roles/acts_as_notifiable.rb +13 -16
- data/lib/activity_notification/version.rb +1 -1
- data/lib/generators/templates/migrations/migration.rb +1 -1
- data/spec/channels/notification_api_channel_spec.rb +42 -44
- data/spec/channels/notification_api_with_devise_channel_spec.rb +57 -59
- data/spec/channels/notification_channel_spec.rb +41 -43
- data/spec/channels/notification_with_devise_channel_spec.rb +75 -77
- data/spec/concerns/common_spec.rb +25 -3
- data/spec/concerns/models/notifiable_spec.rb +35 -35
- data/spec/concerns/models/target_spec.rb +10 -12
- data/spec/concerns/renderable_spec.rb +5 -5
- data/spec/config_spec.rb +26 -15
- data/spec/controllers/controller_spec_utility.rb +15 -51
- data/spec/generators/migration/migration_generator_spec.rb +2 -10
- data/spec/helpers/view_helpers_spec.rb +1 -1
- data/spec/models/subscription_spec.rb +8 -0
- data/spec/optional_targets/action_cable_api_channel_spec.rb +21 -24
- data/spec/optional_targets/action_cable_channel_spec.rb +26 -29
- 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 +6 -7
- data/spec/rails_app/config/dynamoid.rb +11 -3
- data/spec/rails_app/config/environments/production.rb +3 -0
- data/spec/rails_app/config/environments/test.rb +2 -11
- data/spec/rails_app/config/initializers/activity_notification.rb +3 -3
- data/spec/rails_app/config/initializers/copy_it.aws.rb.template +6 -0
- 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
- data/spec/spec_helper.rb +1 -5
- metadata +14 -12
- data/gemfiles/Gemfile.rails-4.2 +0 -23
- data/spec/support/patch_rails_42_action_controller_test_response.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0925836406b562667162fcddb33f8c4e872f2da0cb6e4bfef2fa00d727c48b76'
|
4
|
+
data.tar.gz: 1e9a79db20559fb3c19efb494c7b0d137d653fb79fc8db168df70e84b299224a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c8a1b7f11b9c88350c8565be038c3ac968b850aa8a3f50e683c6c7a4f162e6680c275147db9ad7bbed864b0082984e3e3dfc55bd7cace40592b3017e1ca8b58
|
7
|
+
data.tar.gz: 73f623e03fd9700b24dcbdeabaef9c732e2d22cea15f9b2a1b129812314f6d5dac672d22ed14a93f611903c05f543c344cc3a5e18e3b44d6af3fd677796321e9
|
data/.travis.yml
CHANGED
@@ -5,18 +5,18 @@ branches:
|
|
5
5
|
- images
|
6
6
|
|
7
7
|
rvm:
|
8
|
-
|
9
|
-
- 2.6.
|
10
|
-
# - 2.5.
|
11
|
-
# - 2.4.
|
8
|
+
- 2.7.2
|
9
|
+
# - 2.6.6
|
10
|
+
# - 2.5.8
|
11
|
+
# - 2.4.10 #EOL
|
12
12
|
# - 2.3.8 #EOL
|
13
13
|
|
14
14
|
gemfile:
|
15
|
-
- gemfiles/Gemfile.rails-4.2
|
16
15
|
- gemfiles/Gemfile.rails-5.0
|
17
16
|
- gemfiles/Gemfile.rails-5.1
|
18
17
|
- gemfiles/Gemfile.rails-5.2
|
19
18
|
- gemfiles/Gemfile.rails-6.0
|
19
|
+
- gemfiles/Gemfile.rails-6.1
|
20
20
|
|
21
21
|
env:
|
22
22
|
- AN_ORM=active_record
|
@@ -27,9 +27,6 @@ env:
|
|
27
27
|
- AN_ORM=dynamoid
|
28
28
|
|
29
29
|
matrix:
|
30
|
-
exclude:
|
31
|
-
- gemfile: gemfiles/Gemfile.rails-4.2
|
32
|
-
env: AN_ORM=dynamoid
|
33
30
|
include:
|
34
31
|
- rvm: ruby-head
|
35
32
|
gemfile: Gemfile
|
@@ -40,6 +37,9 @@ matrix:
|
|
40
37
|
- rvm: ruby-head
|
41
38
|
gemfile: Gemfile
|
42
39
|
env: AN_ORM=dynamoid
|
40
|
+
exclude:
|
41
|
+
- gemfile: gemfiles/Gemfile.rails-6.1
|
42
|
+
env: AN_ORM=dynamoid
|
43
43
|
allow_failures:
|
44
44
|
- rvm: ruby-head
|
45
45
|
fast_finish: true
|
@@ -53,18 +53,12 @@ sudo: false
|
|
53
53
|
|
54
54
|
cache: bundler
|
55
55
|
|
56
|
-
before_install:
|
57
|
-
# Specify bundler version as '< 2.0' for Rails 4.2
|
58
|
-
- gem install bundler --no-document -v '1.17.3'
|
59
|
-
|
60
56
|
install:
|
61
|
-
|
62
|
-
- bundle _1.17.3_ install
|
57
|
+
- bundle install
|
63
58
|
- if [ "$AN_ORM" = "dynamoid" ]; then bin/install_dynamodblocal.sh; fi
|
64
59
|
|
65
60
|
before_script:
|
66
|
-
|
67
|
-
- bundle _1.17.3_ update
|
61
|
+
- bundle update
|
68
62
|
- if [ "$AN_TEST_DB" = "mysql" ]; then mysql -e 'create database activity_notification_test'; fi
|
69
63
|
- if [ "$AN_TEST_DB" = "postgresql" ]; then psql -c 'create database activity_notification_test' -U postgres; fi
|
70
64
|
- if [ "$AN_ORM" = "dynamoid" ]; then bin/start_dynamodblocal.sh; fi
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,60 @@
|
|
1
|
+
## 2.2.1 / 2021-01-24
|
2
|
+
[Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.2.0...v2.2.1)
|
3
|
+
|
4
|
+
Enhancements:
|
5
|
+
|
6
|
+
* Allow use with Rails 6.1 - [#152](https://github.com/simukappu/activity_notification/issues/152)
|
7
|
+
|
8
|
+
## 2.2.0 / 2020-12-05
|
9
|
+
[Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.1.4...v2.2.0)
|
10
|
+
|
11
|
+
Enhancements:
|
12
|
+
|
13
|
+
* Remove support for Rails 4.2 - [#151](https://github.com/simukappu/activity_notification/issues/151)
|
14
|
+
* Turn on deprecation warnings in RSpec testing for Ruby 2.7 - [#122](https://github.com/simukappu/activity_notification/issues/122)
|
15
|
+
* Remove Ruby 2.7 deprecation warnings - [#122](https://github.com/simukappu/activity_notification/issues/122)
|
16
|
+
|
17
|
+
Breaking Changes:
|
18
|
+
|
19
|
+
* Specify DynamoDB global secondary index name
|
20
|
+
* Update additional fields to store into DynamoDB when *config.store_with_associated_records* is true
|
21
|
+
|
22
|
+
## 2.1.4 / 2020-11-07
|
23
|
+
[Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.1.3...v2.1.4)
|
24
|
+
|
25
|
+
Enhancements:
|
26
|
+
|
27
|
+
* 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)
|
28
|
+
|
29
|
+
Bug Fixes:
|
30
|
+
|
31
|
+
* 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)
|
32
|
+
* Fix hash syntax in swagger schemas - [#146](https://github.com/simukappu/activity_notification/issues/146) [#147](https://github.com/simukappu/activity_notification/pull/147)
|
33
|
+
|
34
|
+
## 2.1.3 / 2020-08-11
|
35
|
+
[Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.1.2...v2.1.3)
|
36
|
+
|
37
|
+
Enhancements:
|
38
|
+
|
39
|
+
* Enable to use namespaced model - [#132](https://github.com/simukappu/activity_notification/pull/132)
|
40
|
+
|
41
|
+
Bug Fixes:
|
42
|
+
|
43
|
+
* Fix mongoid any_of selector error in filtered_by_group scope - [MONGOID-4887](https://jira.mongodb.org/browse/MONGOID-4887)
|
44
|
+
|
45
|
+
## 2.1.2 / 2020-02-24
|
46
|
+
[Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.1.1...v2.1.2)
|
47
|
+
|
48
|
+
Bug Fixes:
|
49
|
+
|
50
|
+
* Fix scope of uniqueness validation in subscription model with mongoid - [#126](https://github.com/simukappu/activity_notification/issues/126) [#128](https://github.com/simukappu/activity_notification/pull/128)
|
51
|
+
* Fix uninitialized constant DeviseTokenAuth when *config.eager_load = true* - [#129](https://github.com/simukappu/activity_notification/issues/129)
|
52
|
+
|
1
53
|
## 2.1.1 / 2020-02-11
|
2
54
|
[Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.1.0...v2.1.1)
|
3
55
|
|
4
56
|
Bug Fixes:
|
57
|
+
|
5
58
|
* Fix eager_load by autoloading VERSION - [#124](https://github.com/simukappu/activity_notification/issues/124) [#125](https://github.com/simukappu/activity_notification/pull/125)
|
6
59
|
|
7
60
|
## 2.1.0 / 2020-02-04
|
data/Gemfile
CHANGED
@@ -16,14 +16,13 @@ group :development do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
group :test do
|
19
|
-
#TODO https://github.com/rails/rails/issues/35417
|
20
|
-
gem 'rspec-rails', '4.0.0.beta4'
|
21
19
|
gem 'rails-controller-testing'
|
22
20
|
gem 'ammeter'
|
23
21
|
gem 'timecop'
|
24
22
|
gem 'committee'
|
25
23
|
gem 'committee-rails'
|
26
|
-
gem 'coveralls', require: false
|
24
|
+
# gem 'coveralls', require: false
|
25
|
+
gem 'coveralls_reborn', require: false
|
27
26
|
end
|
28
27
|
|
29
28
|
gem 'webpacker', groups: [:production, :development]
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
*activity_notification* provides integrated user activity notifications for [Ruby on Rails](https://rubyonrails.org). You can easily use it to configure multiple notification targets and make activity notifications with notifiable models, like adding comments, responding etc.
|
12
12
|
|
13
|
-
*activity_notification* supports Rails
|
13
|
+
*activity_notification* supports Rails 5.0+ with [ActiveRecord](https://guides.rubyonrails.org/active_record_basics.html), [Mongoid](https://mongoid.org) and [Dynamoid](https://github.com/Dynamoid/dynamoid) ORM. It is tested for [MySQL](https://www.mysql.com), [PostgreSQL](https://www.postgresql.org), [SQLite3](https://www.sqlite.org) with ActiveRecord, [MongoDB](https://www.mongodb.com) with Mongoid and [Amazon DynamoDB](https://aws.amazon.com/dynamodb) with Dynamoid. If you are using Rails 4.2, use [v2.1.4](https://rubygems.org/gems/activity_notification/versions/2.1.4) or older version of *activity_notification*.
|
14
14
|
|
15
15
|
|
16
16
|
## About
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
s.required_ruby_version = '>= 2.1.0'
|
22
22
|
|
23
|
-
s.add_dependency 'railties', '>=
|
23
|
+
s.add_dependency 'railties', '>= 5.0.0', '< 6.2'
|
24
24
|
s.add_dependency 'i18n', '>= 0.5.0'
|
25
25
|
s.add_dependency 'jquery-rails', '>= 3.1.1'
|
26
26
|
s.add_dependency 'swagger-blocks', '>= 3.0.0'
|
@@ -24,7 +24,7 @@ if defined?(ActionCable)
|
|
24
24
|
# @return [Object] Target instance (Reject subscription when request parameters are not enough)
|
25
25
|
def set_target
|
26
26
|
reject and return if (target_type = params[:target_type]).blank?
|
27
|
-
if params[:target_id].blank? && params["#{target_type.to_s.to_resource_name}_id"].blank?
|
27
|
+
if params[:target_id].blank? && params["#{target_type.to_s.to_resource_name[/([^\/]+)$/]}_id"].blank?
|
28
28
|
reject and return if params[:devise_type].blank?
|
29
29
|
current_target = find_current_target(params[:devise_type])
|
30
30
|
params[:target_id] = target_type.to_model_class.resolve_current_devise_target(current_target)
|
@@ -22,7 +22,7 @@ if defined?(ActionCable)
|
|
22
22
|
target_class = target_type.to_s.to_model_class
|
23
23
|
@target = params[:target_id].present? ?
|
24
24
|
target_class.find_by!(id: params[:target_id]) :
|
25
|
-
target_class.find_by!(id: params["#{target_type.to_s.to_resource_name}_id"])
|
25
|
+
target_class.find_by!(id: params["#{target_type.to_s.to_resource_name[/([^\/]+)$/]}_id"])
|
26
26
|
rescue
|
27
27
|
reject
|
28
28
|
end
|
@@ -29,7 +29,7 @@ if defined?(ActionCable)
|
|
29
29
|
# @return [Object] Target instance (Reject subscription when request parameters are not enough)
|
30
30
|
def set_target
|
31
31
|
reject and return if (target_type = params[:target_type]).blank?
|
32
|
-
if params[:target_id].blank? && params["#{target_type.to_s.to_resource_name}_id"].blank?
|
32
|
+
if params[:target_id].blank? && params["#{target_type.to_s.to_resource_name[/([^\/]+)$/]}_id"].blank?
|
33
33
|
reject and return if params[:devise_type].blank?
|
34
34
|
current_target = find_current_target(params[:devise_type])
|
35
35
|
params[:target_id] = target_type.to_model_class.resolve_current_devise_target(current_target)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module ActivityNotification
|
2
2
|
# Controller to manage notifications API with Devise authentication.
|
3
3
|
class NotificationsApiWithDeviseController < NotificationsApiController
|
4
|
-
include DeviseTokenAuth::Concerns::SetUserByToken
|
4
|
+
include DeviseTokenAuth::Concerns::SetUserByToken if defined?(DeviseTokenAuth)
|
5
5
|
include DeviseAuthenticationController
|
6
6
|
end
|
7
7
|
end
|
@@ -117,26 +117,6 @@ module ActivityNotification
|
|
117
117
|
super
|
118
118
|
end
|
119
119
|
|
120
|
-
# :nocov:
|
121
|
-
if Rails::VERSION::MAJOR == 4
|
122
|
-
# Defines custom renderer class method for Rails 4.2
|
123
|
-
def self.renderer
|
124
|
-
view_context = ActionView::Base.new(ActionController::Base.view_paths, {})
|
125
|
-
view_context.class_eval do
|
126
|
-
include Rails.application.routes.url_helpers
|
127
|
-
def default_url_options
|
128
|
-
ActionMailer::Base.default_url_options
|
129
|
-
end
|
130
|
-
def render(params = {})
|
131
|
-
assign(params[:assigns])
|
132
|
-
super(params)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
view_context
|
136
|
-
end
|
137
|
-
end
|
138
|
-
# :nocov:
|
139
|
-
|
140
120
|
protected
|
141
121
|
|
142
122
|
# Sets @notification instance variable from request parameters.
|
@@ -44,7 +44,7 @@ module ActivityNotification
|
|
44
44
|
params[:subscription][:optional_targets]["subscribing_to_#{optional_target_name}"] = subscribing_param unless subscribing_param.nil?
|
45
45
|
end
|
46
46
|
super
|
47
|
-
render status: 201,
|
47
|
+
render status: 201, json: subscription_json if @subscription
|
48
48
|
end
|
49
49
|
|
50
50
|
# Finds and shows a subscription from specified key.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module ActivityNotification
|
2
2
|
# Controller to manage subscriptions API with Devise authentication.
|
3
3
|
class SubscriptionsApiWithDeviseController < SubscriptionsApiController
|
4
|
-
include DeviseTokenAuth::Concerns::SetUserByToken
|
4
|
+
include DeviseTokenAuth::Concerns::SetUserByToken if defined?(DeviseTokenAuth)
|
5
5
|
include DeviseAuthenticationController
|
6
6
|
end
|
7
7
|
end
|
data/bin/bundle_update.sh
CHANGED
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
|
|
@@ -343,6 +456,20 @@ end
|
|
343
456
|
Then, you can access several pages like */users/1/notifications* and manage open/unopen of notifications using *[ActivityNotification::NotificationsController](/app/controllers/activity_notification/notifications_controller.rb)*.
|
344
457
|
If you use Devise integration and you want to configure simple default routes for authenticated users, see [Configuring simple default routes](#configuring-simple-default-routes).
|
345
458
|
|
459
|
+
#### Routes with namespaced model
|
460
|
+
|
461
|
+
It is possible to configure a target model as a submodule, e.g. if your target is `Entity::User`,
|
462
|
+
however by default the **ActivityNotification** controllers will be placed under the same namespace,
|
463
|
+
so it is mandatory to explicitly call the controllers this way
|
464
|
+
|
465
|
+
```ruby
|
466
|
+
Rails.application.routes.draw do
|
467
|
+
notify_to :users, controller: '/activity_notification/notifications', target_type: 'entity/users'
|
468
|
+
end
|
469
|
+
```
|
470
|
+
|
471
|
+
This will generate the necessary routes for the `Entity::User` target with parameters `:user_id`
|
472
|
+
|
346
473
|
#### Routes with scope
|
347
474
|
|
348
475
|
You can also configure *activity_notification* routes with scope like this:
|