activity_notification 2.1.1 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +10 -16
  3. data/CHANGELOG.md +53 -0
  4. data/Gemfile +2 -3
  5. data/README.md +1 -1
  6. data/activity_notification.gemspec +1 -1
  7. data/app/channels/activity_notification/notification_api_with_devise_channel.rb +1 -1
  8. data/app/channels/activity_notification/notification_channel.rb +1 -1
  9. data/app/channels/activity_notification/notification_with_devise_channel.rb +1 -1
  10. data/app/controllers/activity_notification/notifications_api_with_devise_controller.rb +1 -1
  11. data/app/controllers/activity_notification/notifications_controller.rb +0 -20
  12. data/app/controllers/activity_notification/subscriptions_api_controller.rb +1 -1
  13. data/app/controllers/activity_notification/subscriptions_api_with_devise_controller.rb +1 -1
  14. data/bin/bundle_update.sh +0 -1
  15. data/docs/Functions.md +2 -2
  16. data/docs/Setup.md +190 -63
  17. data/gemfiles/Gemfile.rails-5.0 +3 -1
  18. data/gemfiles/Gemfile.rails-5.1 +3 -1
  19. data/gemfiles/Gemfile.rails-5.2 +3 -1
  20. data/gemfiles/Gemfile.rails-6.0 +2 -3
  21. data/gemfiles/Gemfile.rails-6.1 +24 -0
  22. data/lib/activity_notification/apis/notification_api.rb +7 -0
  23. data/lib/activity_notification/common.rb +15 -4
  24. data/lib/activity_notification/controllers/common_controller.rb +2 -18
  25. data/lib/activity_notification/models/concerns/notifiable.rb +12 -12
  26. data/lib/activity_notification/models/concerns/swagger/notification_schema.rb +34 -34
  27. data/lib/activity_notification/models/concerns/swagger/subscription_schema.rb +17 -17
  28. data/lib/activity_notification/models/concerns/target.rb +5 -9
  29. data/lib/activity_notification/optional_targets/action_cable_api_channel.rb +1 -1
  30. data/lib/activity_notification/optional_targets/action_cable_channel.rb +1 -1
  31. data/lib/activity_notification/orm/active_record.rb +1 -1
  32. data/lib/activity_notification/orm/active_record/notification.rb +3 -3
  33. data/lib/activity_notification/orm/dynamoid.rb +10 -3
  34. data/lib/activity_notification/orm/dynamoid/notification.rb +49 -14
  35. data/lib/activity_notification/orm/dynamoid/subscription.rb +1 -1
  36. data/lib/activity_notification/orm/mongoid.rb +10 -3
  37. data/lib/activity_notification/orm/mongoid/notification.rb +8 -6
  38. data/lib/activity_notification/orm/mongoid/subscription.rb +1 -1
  39. data/lib/activity_notification/renderable.rb +2 -2
  40. data/lib/activity_notification/roles/acts_as_notifiable.rb +13 -16
  41. data/lib/activity_notification/version.rb +1 -1
  42. data/lib/generators/templates/migrations/migration.rb +1 -1
  43. data/spec/channels/notification_api_channel_spec.rb +42 -44
  44. data/spec/channels/notification_api_with_devise_channel_spec.rb +57 -59
  45. data/spec/channels/notification_channel_spec.rb +41 -43
  46. data/spec/channels/notification_with_devise_channel_spec.rb +75 -77
  47. data/spec/concerns/common_spec.rb +25 -3
  48. data/spec/concerns/models/notifiable_spec.rb +35 -35
  49. data/spec/concerns/models/target_spec.rb +10 -12
  50. data/spec/concerns/renderable_spec.rb +5 -5
  51. data/spec/config_spec.rb +26 -15
  52. data/spec/controllers/controller_spec_utility.rb +15 -51
  53. data/spec/generators/migration/migration_generator_spec.rb +2 -10
  54. data/spec/helpers/view_helpers_spec.rb +1 -1
  55. data/spec/models/subscription_spec.rb +8 -0
  56. data/spec/optional_targets/action_cable_api_channel_spec.rb +21 -24
  57. data/spec/optional_targets/action_cable_channel_spec.rb +26 -29
  58. data/spec/rails_app/app/controllers/users_controller.rb +5 -0
  59. data/spec/rails_app/app/javascript/App.vue +8 -72
  60. data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +3 -4
  61. data/spec/rails_app/app/javascript/components/Top.vue +2 -3
  62. data/spec/rails_app/app/javascript/packs/spa.js +6 -3
  63. data/spec/rails_app/app/javascript/router/index.js +73 -0
  64. data/spec/rails_app/app/javascript/store/{auth.js → index.js} +0 -0
  65. data/spec/rails_app/app/models/dummy/dummy_group.rb +8 -0
  66. data/spec/rails_app/app/models/dummy/dummy_notifiable_target.rb +8 -0
  67. data/spec/rails_app/app/models/user.rb +2 -1
  68. data/spec/rails_app/config/application.rb +6 -7
  69. data/spec/rails_app/config/dynamoid.rb +11 -3
  70. data/spec/rails_app/config/environments/production.rb +3 -0
  71. data/spec/rails_app/config/environments/test.rb +2 -11
  72. data/spec/rails_app/config/initializers/activity_notification.rb +3 -3
  73. data/spec/rails_app/config/initializers/copy_it.aws.rb.template +6 -0
  74. data/spec/rails_app/config/routes.rb +5 -1
  75. data/spec/rails_app/db/seeds.rb +9 -2
  76. data/spec/roles/acts_as_notifiable_spec.rb +5 -5
  77. data/spec/spec_helper.rb +1 -5
  78. metadata +14 -12
  79. data/gemfiles/Gemfile.rails-4.2 +0 -23
  80. 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: 20341262e3b9f892cd609a69a7f5130155592a5b3e43d8d905ec6210b31db68f
4
- data.tar.gz: 4f8f627d667e712420b9ed1e2dccaaaa3fe00e74be3a7c84770a1aecbec39143
3
+ metadata.gz: '0925836406b562667162fcddb33f8c4e872f2da0cb6e4bfef2fa00d727c48b76'
4
+ data.tar.gz: 1e9a79db20559fb3c19efb494c7b0d137d653fb79fc8db168df70e84b299224a
5
5
  SHA512:
6
- metadata.gz: f82266c7341114ac6e39aca9d7daee5734a204d7f4f0948d7f8ace6fa047ce1edc3ff3041b776ed32cf38cca343e6f0919b94a348b9c740e1efd4d5b82253e61
7
- data.tar.gz: 725129b9714995fd1b70866e737b535cf2bca972d77ab12353bd1e7f9a11c752313f13d3f4a0d1c9699e60d70a192020b2948b717b38b6912445eb5f90178f6a
6
+ metadata.gz: 6c8a1b7f11b9c88350c8565be038c3ac968b850aa8a3f50e683c6c7a4f162e6680c275147db9ad7bbed864b0082984e3e3dfc55bd7cace40592b3017e1ca8b58
7
+ data.tar.gz: 73f623e03fd9700b24dcbdeabaef9c732e2d22cea15f9b2a1b129812314f6d5dac672d22ed14a93f611903c05f543c344cc3a5e18e3b44d6af3fd677796321e9
@@ -5,18 +5,18 @@ branches:
5
5
  - images
6
6
 
7
7
  rvm:
8
- # - 2.7.0 # Need to respond to warnings for Ruby 3.0
9
- - 2.6.5
10
- # - 2.5.7
11
- # - 2.4.9
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
- # Specify bundler version as '< 2.0' for Rails 4.2
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
- # Specify bundler version as '< 2.0' for Rails 4.2
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
@@ -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 4.2+ 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. The latest *activity_notification* [v2](https://rubygems.org/gems/activity_notification) is almost compatible with [v1](https://rubygems.org/gems/activity_notification/versions/1.7.1).
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', '>= 4.2.0', '< 6.1'
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, location: { action: :show, id: @subscription }, json: subscription_json
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
@@ -1,7 +1,6 @@
1
1
  #!/bin/bash
2
2
 
3
3
  bundle update
4
- BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.2 bundle update
5
4
  BUNDLE_GEMFILE=gemfiles/Gemfile.rails-5.0 bundle update
6
5
  BUNDLE_GEMFILE=gemfiles/Gemfile.rails-5.1 bundle update
7
6
  BUNDLE_GEMFILE=gemfiles/Gemfile.rails-5.2 bundle update
@@ -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 is 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)*.
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 look for a partial in *default* as the target type which means *activity_notification/mailer/default/_default.html.(|erb|haml|slim|something_else)*.
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
 
@@ -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
- "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
- "N": "1560085332.689929"
132
- },
133
- "updated_at": {
134
- "N": "1560085332.695515"
135
- },
136
- "parameters": {
137
- "M": {}
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 notifier like this:
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
- "id": {
147
- "S": "f05756ef-661e-4ef5-9e99-5af51243125c"
148
- },
149
- "target_key": {
150
- "S": "User#1"
151
- },
152
- "target_record": {
153
- "S": "{\"id\":1,\"email\":\"ichiro@example.com\",\"name\":\"Ichiro\",\"created_at\":\"2019-06-09T13:10:44.853Z\",\"updated_at\":\"2019-06-09T13:10:44.853Z\"}"
154
- },
155
- "notifiable_key": {
156
- "S": "Comment#2"
157
- },
158
- "notifiable_record": {
159
- "S": "{\"id\":2,\"user_id\":2,\"article_id\":1,\"body\":\"This is the first Stephen's comment to Ichiro's article.\",\"created_at\":\"2019-06-09T13:10:45.677Z\",\"updated_at\":\"2019-06-09T13:10:45.677Z\"}"
160
- },
161
- "key": {
162
- "S": "comment.default"
163
- },
164
- "group_key": {
165
- "S": "Article#1"
166
- },
167
- "notifier_key": {
168
- "S": "User#2"
169
- },
170
- "notifier_record": {
171
- "S": "{\"id\":2,\"email\":\"stephen@example.com\",\"name\":\"Stephen\",\"created_at\":\"2019-06-09T13:10:45.006Z\",\"updated_at\":\"2019-06-09T13:10:45.006Z\"}"
172
- },
173
- "created_at": {
174
- "N": "1560085332.689929"
175
- },
176
- "updated_at": {
177
- "N": "1560085332.695515"
178
- },
179
- "parameters": {
180
- "M": {}
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: