activity_notification 1.4.4 → 2.2.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 +5 -5
- data/.github/ISSUE_TEMPLATE/bug_report.md +22 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- data/.github/pull_request_template.md +13 -0
- data/.github/workflows/build.yml +116 -0
- data/.gitignore +15 -3
- data/CHANGELOG.md +200 -1
- data/Gemfile +17 -2
- data/Procfile +2 -0
- data/README.md +168 -1033
- data/Rakefile +19 -10
- data/activity_notification.gemspec +14 -9
- data/app/channels/activity_notification/notification_api_channel.rb +12 -0
- data/app/channels/activity_notification/notification_api_with_devise_channel.rb +46 -0
- data/app/channels/activity_notification/notification_channel.rb +37 -0
- data/app/channels/activity_notification/notification_with_devise_channel.rb +51 -0
- data/app/controllers/activity_notification/apidocs_controller.rb +75 -0
- data/app/controllers/activity_notification/notifications_api_controller.rb +143 -0
- data/app/controllers/activity_notification/notifications_api_with_devise_controller.rb +7 -0
- data/app/controllers/activity_notification/notifications_controller.rb +60 -54
- data/app/controllers/activity_notification/subscriptions_api_controller.rb +197 -0
- data/app/controllers/activity_notification/subscriptions_api_with_devise_controller.rb +7 -0
- data/app/controllers/activity_notification/subscriptions_controller.rb +83 -73
- data/app/jobs/activity_notification/notify_all_job.rb +25 -0
- data/app/jobs/activity_notification/notify_job.rb +26 -0
- data/app/jobs/activity_notification/notify_to_job.rb +25 -0
- data/app/views/activity_notification/notifications/default/_default.html.erb +23 -23
- data/app/views/activity_notification/notifications/default/_default_without_grouping.html.erb +19 -19
- data/app/views/activity_notification/notifications/default/_index.html.erb +3 -3
- data/app/views/activity_notification/notifications/default/index.html.erb +60 -7
- data/app/views/activity_notification/notifications/default/open.js.erb +2 -2
- data/app/views/activity_notification/notifications/default/open_all.js.erb +2 -2
- data/app/views/activity_notification/notifications/default/show.html.erb +2 -2
- data/app/views/activity_notification/optional_targets/default/action_cable_channel/_default.html.erb +176 -0
- data/app/views/activity_notification/optional_targets/default/base/_default.text.erb +1 -1
- data/app/views/activity_notification/optional_targets/default/slack/_default.text.erb +1 -1
- data/app/views/activity_notification/subscriptions/default/_form.html.erb +2 -2
- data/app/views/activity_notification/subscriptions/default/_notification_keys.html.erb +5 -33
- data/app/views/activity_notification/subscriptions/default/_subscription.html.erb +8 -8
- data/app/views/activity_notification/subscriptions/default/index.html.erb +13 -9
- data/app/views/activity_notification/subscriptions/default/show.html.erb +3 -3
- data/app/views/activity_notification/subscriptions/default/subscribe.js.erb +1 -1
- data/app/views/activity_notification/subscriptions/default/subscribe_to_email.js.erb +1 -1
- data/app/views/activity_notification/subscriptions/default/subscribe_to_optional_target.js.erb +1 -1
- data/app/views/activity_notification/subscriptions/default/unsubscribe.js.erb +1 -1
- data/app/views/activity_notification/subscriptions/default/unsubscribe_to_email.js.erb +1 -1
- data/app/views/activity_notification/subscriptions/default/unsubscribe_to_optional_target.js.erb +1 -1
- data/bin/_dynamodblocal +4 -0
- data/bin/bundle_update.sh +7 -0
- data/bin/deploy_on_heroku.sh +16 -0
- data/bin/install_dynamodblocal.sh +5 -0
- data/bin/start_dynamodblocal.sh +47 -0
- data/bin/stop_dynamodblocal.sh +34 -0
- data/docs/CODE_OF_CONDUCT.md +76 -0
- data/docs/CONTRIBUTING.md +36 -0
- data/docs/Functions.md +1146 -0
- data/docs/Setup.md +817 -0
- data/docs/Testing.md +148 -0
- data/gemfiles/Gemfile.rails-5.0 +8 -1
- data/gemfiles/Gemfile.rails-5.1 +7 -1
- data/gemfiles/Gemfile.rails-5.2 +24 -0
- data/gemfiles/Gemfile.rails-6.0 +23 -0
- data/gemfiles/Gemfile.rails-6.1 +22 -0
- data/gemfiles/Gemfile.rails-7.0 +25 -0
- data/lib/activity_notification/apis/notification_api.rb +356 -159
- data/lib/activity_notification/apis/subscription_api.rb +98 -59
- data/lib/activity_notification/apis/swagger.rb +6 -0
- data/lib/activity_notification/common.rb +18 -7
- data/lib/activity_notification/config.rb +176 -30
- data/lib/activity_notification/controllers/common_api_controller.rb +30 -0
- data/lib/activity_notification/controllers/common_controller.rb +47 -27
- data/lib/activity_notification/controllers/concerns/swagger/error_responses.rb +55 -0
- data/lib/activity_notification/controllers/concerns/swagger/notifications_api.rb +273 -0
- data/lib/activity_notification/controllers/concerns/swagger/notifications_parameters.rb +92 -0
- data/lib/activity_notification/controllers/concerns/swagger/subscriptions_api.rb +405 -0
- data/lib/activity_notification/controllers/concerns/swagger/subscriptions_parameters.rb +50 -0
- data/lib/activity_notification/controllers/devise_authentication_controller.rb +22 -5
- data/lib/activity_notification/gem_version.rb +14 -0
- data/lib/activity_notification/helpers/errors.rb +6 -0
- data/lib/activity_notification/helpers/view_helpers.rb +118 -28
- data/lib/activity_notification/mailers/helpers.rb +19 -12
- data/lib/activity_notification/models/concerns/notifiable.rb +142 -55
- data/lib/activity_notification/models/concerns/subscriber.rb +28 -13
- data/lib/activity_notification/models/concerns/swagger/error_schema.rb +36 -0
- data/lib/activity_notification/models/concerns/swagger/notification_schema.rb +209 -0
- data/lib/activity_notification/models/concerns/swagger/subscription_schema.rb +162 -0
- data/lib/activity_notification/models/concerns/target.rb +131 -32
- data/lib/activity_notification/models/notification.rb +1 -0
- data/lib/activity_notification/models/subscription.rb +1 -0
- data/lib/activity_notification/models.rb +23 -1
- data/lib/activity_notification/optional_targets/action_cable_api_channel.rb +69 -0
- data/lib/activity_notification/optional_targets/action_cable_channel.rb +68 -0
- data/lib/activity_notification/optional_targets/base.rb +9 -15
- data/lib/activity_notification/orm/active_record/notification.rb +23 -34
- data/lib/activity_notification/orm/active_record/subscription.rb +1 -1
- data/lib/activity_notification/orm/active_record.rb +1 -1
- data/lib/activity_notification/orm/dynamoid/extension.rb +262 -0
- data/lib/activity_notification/orm/dynamoid/notification.rb +224 -0
- data/lib/activity_notification/orm/dynamoid/subscription.rb +82 -0
- data/lib/activity_notification/orm/dynamoid.rb +530 -0
- data/lib/activity_notification/orm/mongoid/notification.rb +29 -28
- data/lib/activity_notification/orm/mongoid/subscription.rb +3 -3
- data/lib/activity_notification/orm/mongoid.rb +33 -1
- data/lib/activity_notification/rails/routes.rb +273 -60
- data/lib/activity_notification/renderable.rb +22 -7
- data/lib/activity_notification/roles/acts_as_notifiable.rb +64 -1
- data/lib/activity_notification/roles/acts_as_target.rb +99 -9
- data/lib/activity_notification/version.rb +1 -1
- data/lib/activity_notification.rb +14 -0
- data/lib/generators/activity_notification/controllers_generator.rb +2 -1
- data/lib/generators/templates/activity_notification.rb +61 -7
- data/lib/generators/templates/controllers/README +2 -2
- data/lib/generators/templates/controllers/notifications_api_controller.rb +31 -0
- data/lib/generators/templates/controllers/notifications_api_with_devise_controller.rb +31 -0
- data/lib/generators/templates/controllers/notifications_controller.rb +1 -37
- data/lib/generators/templates/controllers/notifications_with_devise_controller.rb +1 -45
- data/lib/generators/templates/controllers/subscriptions_api_controller.rb +61 -0
- data/lib/generators/templates/controllers/subscriptions_api_with_devise_controller.rb +61 -0
- data/lib/generators/templates/controllers/subscriptions_controller.rb +14 -37
- data/lib/generators/templates/controllers/subscriptions_with_devise_controller.rb +14 -45
- data/lib/generators/templates/migrations/migration.rb +5 -5
- data/lib/generators/templates/models/README +8 -4
- data/lib/generators/templates/models/notification.rb +1 -1
- data/lib/generators/templates/models/subscription.rb +1 -1
- data/lib/tasks/activity_notification_tasks.rake +14 -4
- data/package.json +8 -0
- data/spec/channels/notification_api_channel_shared_examples.rb +59 -0
- data/spec/channels/notification_api_channel_spec.rb +49 -0
- data/spec/channels/notification_api_with_devise_channel_spec.rb +76 -0
- data/spec/channels/notification_channel_shared_examples.rb +59 -0
- data/spec/channels/notification_channel_spec.rb +48 -0
- data/spec/channels/notification_with_devise_channel_spec.rb +97 -0
- data/spec/concerns/apis/notification_api_spec.rb +177 -12
- data/spec/concerns/apis/subscription_api_spec.rb +146 -4
- data/spec/concerns/common_spec.rb +25 -3
- data/spec/concerns/models/notifiable_spec.rb +161 -11
- data/spec/concerns/models/subscriber_spec.rb +253 -79
- data/spec/concerns/models/target_spec.rb +180 -47
- data/spec/concerns/renderable_spec.rb +35 -16
- data/spec/config_spec.rb +52 -1
- data/spec/controllers/controller_spec_utility.rb +100 -0
- data/spec/controllers/notifications_api_controller_shared_examples.rb +506 -0
- data/spec/controllers/notifications_api_controller_spec.rb +19 -0
- data/spec/controllers/notifications_api_with_devise_controller_spec.rb +60 -0
- data/spec/controllers/notifications_controller_shared_examples.rb +55 -76
- data/spec/controllers/notifications_controller_spec.rb +1 -2
- data/spec/controllers/notifications_with_devise_controller_spec.rb +14 -8
- data/spec/controllers/subscriptions_api_controller_shared_examples.rb +750 -0
- data/spec/controllers/subscriptions_api_controller_spec.rb +19 -0
- data/spec/controllers/subscriptions_api_with_devise_controller_spec.rb +60 -0
- data/spec/controllers/subscriptions_controller_shared_examples.rb +99 -121
- data/spec/controllers/subscriptions_controller_spec.rb +1 -2
- data/spec/controllers/subscriptions_with_devise_controller_spec.rb +14 -8
- data/spec/factories/notifications.rb +1 -1
- data/spec/factories/subscriptions.rb +3 -3
- data/spec/factories/users.rb +3 -3
- data/spec/generators/migration/migration_generator_spec.rb +29 -4
- data/spec/helpers/view_helpers_spec.rb +31 -21
- data/spec/jobs/notify_all_job_spec.rb +23 -0
- data/spec/jobs/notify_job_spec.rb +23 -0
- data/spec/jobs/notify_to_job_spec.rb +23 -0
- data/spec/mailers/mailer_spec.rb +42 -1
- data/spec/models/dummy/dummy_group_spec.rb +4 -0
- data/spec/models/dummy/dummy_notifiable_spec.rb +4 -0
- data/spec/models/dummy/dummy_notifier_spec.rb +4 -0
- data/spec/models/dummy/dummy_subscriber_spec.rb +3 -0
- data/spec/models/dummy/dummy_target_spec.rb +4 -0
- data/spec/models/notification_spec.rb +181 -45
- data/spec/models/subscription_spec.rb +77 -27
- data/spec/optional_targets/action_cable_api_channel_spec.rb +34 -0
- data/spec/optional_targets/action_cable_channel_spec.rb +41 -0
- data/spec/optional_targets/amazon_sns_spec.rb +0 -2
- data/spec/optional_targets/slack_spec.rb +0 -2
- data/spec/orm/dynamoid_spec.rb +115 -0
- data/spec/rails_app/Rakefile +9 -0
- data/spec/rails_app/app/assets/config/manifest.js +3 -0
- data/spec/rails_app/app/assets/javascripts/application.js +2 -1
- data/spec/rails_app/app/assets/javascripts/cable.js +12 -0
- data/spec/rails_app/app/controllers/admins_controller.rb +21 -0
- data/spec/rails_app/app/controllers/application_controller.rb +1 -1
- data/spec/rails_app/app/controllers/articles_controller.rb +6 -1
- data/spec/rails_app/app/controllers/comments_controller.rb +3 -1
- data/spec/rails_app/app/controllers/spa_controller.rb +7 -0
- data/spec/rails_app/app/controllers/users/notifications_controller.rb +0 -65
- data/spec/rails_app/app/controllers/users/notifications_with_devise_controller.rb +0 -73
- data/spec/rails_app/app/controllers/users/subscriptions_controller.rb +0 -77
- data/spec/rails_app/app/controllers/users/subscriptions_with_devise_controller.rb +0 -85
- data/spec/rails_app/app/controllers/users_controller.rb +26 -0
- data/spec/rails_app/app/javascript/App.vue +40 -0
- data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +82 -0
- data/spec/rails_app/app/javascript/components/Top.vue +98 -0
- data/spec/rails_app/app/javascript/components/notifications/Index.vue +200 -0
- data/spec/rails_app/app/javascript/components/notifications/Notification.vue +133 -0
- data/spec/rails_app/app/javascript/components/notifications/NotificationContent.vue +122 -0
- data/spec/rails_app/app/javascript/components/subscriptions/Index.vue +279 -0
- data/spec/rails_app/app/javascript/components/subscriptions/NewSubscription.vue +112 -0
- data/spec/rails_app/app/javascript/components/subscriptions/NotificationKey.vue +141 -0
- data/spec/rails_app/app/javascript/components/subscriptions/Subscription.vue +226 -0
- data/spec/rails_app/app/javascript/config/development.js +5 -0
- data/spec/rails_app/app/javascript/config/environment.js +7 -0
- data/spec/rails_app/app/javascript/config/production.js +5 -0
- data/spec/rails_app/app/javascript/config/test.js +5 -0
- data/spec/rails_app/app/javascript/packs/application.js +18 -0
- data/spec/rails_app/app/javascript/packs/spa.js +14 -0
- data/spec/rails_app/app/javascript/router/index.js +73 -0
- data/spec/rails_app/app/javascript/store/index.js +37 -0
- data/spec/rails_app/app/models/admin.rb +15 -10
- data/spec/rails_app/app/models/article.rb +25 -20
- data/spec/rails_app/app/models/comment.rb +27 -62
- data/spec/rails_app/app/models/dummy/dummy_base.rb +1 -0
- data/spec/rails_app/app/models/dummy/dummy_group.rb +9 -0
- data/spec/rails_app/app/models/dummy/dummy_notifiable.rb +1 -0
- data/spec/rails_app/app/models/dummy/dummy_notifiable_target.rb +27 -0
- data/spec/rails_app/app/models/dummy/dummy_notifier.rb +1 -0
- data/spec/rails_app/app/models/dummy/dummy_subscriber.rb +1 -0
- data/spec/rails_app/app/models/dummy/dummy_target.rb +1 -0
- data/spec/rails_app/app/models/user.rb +44 -18
- data/spec/rails_app/app/views/activity_notification/notifications/default/article/_update.html.erb +146 -0
- data/spec/rails_app/app/views/activity_notification/notifications/users/overridden/custom/_test.html.erb +1 -0
- data/spec/rails_app/app/views/activity_notification/optional_targets/admins/amazon_sns/comment/_default.text.erb +1 -1
- data/spec/rails_app/app/views/articles/index.html.erb +68 -20
- data/spec/rails_app/app/views/articles/show.html.erb +1 -1
- data/spec/rails_app/app/views/layouts/_header.html.erb +9 -3
- data/spec/rails_app/app/views/spa/index.html.erb +2 -0
- data/spec/rails_app/babel.config.js +72 -0
- data/spec/rails_app/bin/webpack +18 -0
- data/spec/rails_app/bin/webpack-dev-server +18 -0
- data/spec/rails_app/config/application.rb +26 -6
- data/spec/rails_app/config/cable.yml +8 -0
- data/spec/rails_app/config/database.yml +1 -1
- data/spec/rails_app/config/dynamoid.rb +13 -0
- data/spec/rails_app/config/environment.rb +5 -1
- data/spec/rails_app/config/environments/development.rb +5 -0
- data/spec/rails_app/config/environments/production.rb +7 -1
- data/spec/rails_app/config/environments/test.rb +7 -11
- data/spec/rails_app/config/initializers/activity_notification.rb +63 -9
- data/spec/rails_app/config/initializers/copy_it.aws.rb.template +6 -0
- data/spec/rails_app/config/initializers/devise_token_auth.rb +55 -0
- data/spec/rails_app/config/initializers/mysql.rb +9 -0
- data/spec/rails_app/config/locales/activity_notification.en.yml +10 -4
- data/spec/rails_app/config/routes.rb +42 -1
- data/spec/rails_app/config/webpack/development.js +5 -0
- data/spec/rails_app/config/webpack/environment.js +7 -0
- data/spec/rails_app/config/webpack/loaders/vue.js +6 -0
- data/spec/rails_app/config/webpack/production.js +5 -0
- data/spec/rails_app/config/webpack/test.js +5 -0
- data/spec/rails_app/config/webpacker.yml +97 -0
- data/spec/rails_app/db/migrate/{20160715050433_create_test_tables.rb → 20160716000000_create_test_tables.rb} +1 -1
- data/spec/rails_app/db/migrate/{20160715050420_create_activity_notification_tables.rb → 20181209000000_create_activity_notification_tables.rb} +3 -3
- data/spec/rails_app/db/migrate/20191201000000_add_tokens_to_users.rb +10 -0
- data/spec/rails_app/db/schema.rb +46 -43
- data/spec/rails_app/db/seeds.rb +28 -4
- data/spec/rails_app/lib/custom_optional_targets/raise_error.rb +14 -0
- data/spec/rails_app/lib/mailer_previews/mailer_preview.rb +14 -4
- data/spec/rails_app/package.json +23 -0
- data/spec/rails_app/postcss.config.js +12 -0
- data/spec/roles/acts_as_group_spec.rb +0 -2
- data/spec/roles/acts_as_notifiable_spec.rb +80 -20
- data/spec/roles/acts_as_notifier_spec.rb +0 -2
- data/spec/roles/acts_as_target_spec.rb +1 -5
- data/spec/spec_helper.rb +13 -11
- data/spec/version_spec.rb +31 -0
- metadata +306 -53
- data/.travis.yml +0 -85
- data/Gemfile.lock +0 -234
- data/gemfiles/Gemfile.rails-4.2 +0 -17
- data/gemfiles/Gemfile.rails-4.2.lock +0 -225
- data/gemfiles/Gemfile.rails-5.0.lock +0 -234
- data/gemfiles/Gemfile.rails-5.1.lock +0 -234
- data/spec/rails_app/app/views/activity_notification/notifications/users/overriden/custom/_test.html.erb +0 -1
- /data/spec/rails_app/app/{models → assets/images}/.keep +0 -0
|
@@ -95,6 +95,30 @@ module ActivityNotification
|
|
|
95
95
|
# acts_as_notifiable :users, targets: User.all, email_allowed: true
|
|
96
96
|
# end
|
|
97
97
|
#
|
|
98
|
+
# * :action_cable_allowed
|
|
99
|
+
# * Whether activity_notification publishes notifications to ActionCable channel.
|
|
100
|
+
# Specified method or symbol is expected to return true (not nil) or false (nil).
|
|
101
|
+
# This parameter is a optional since default value is false.
|
|
102
|
+
# To use ActionCable for notifications, action_cable_allowed option of target model must also return true (not nil).
|
|
103
|
+
# This can be also configured default option in initializer as action_cable_enabled.
|
|
104
|
+
# @example Enable notification ActionCable for this notifiable model
|
|
105
|
+
# # app/models/comment.rb
|
|
106
|
+
# class Comment < ActiveRecord::Base
|
|
107
|
+
# acts_as_notifiable :users, targets: User.all, action_cable_allowed: true
|
|
108
|
+
# end
|
|
109
|
+
#
|
|
110
|
+
# * :action_cable_api_allowed
|
|
111
|
+
# * Whether activity_notification publishes notifications to ActionCable API channel.
|
|
112
|
+
# Specified method or symbol is expected to return true (not nil) or false (nil).
|
|
113
|
+
# This parameter is a optional since default value is false.
|
|
114
|
+
# To use ActionCable for notifications, action_cable_allowed option of target model must also return true (not nil).
|
|
115
|
+
# This can be also configured default option in initializer as action_cable_api_enabled.
|
|
116
|
+
# @example Enable notification ActionCable for this notifiable model
|
|
117
|
+
# # app/models/comment.rb
|
|
118
|
+
# class Comment < ActiveRecord::Base
|
|
119
|
+
# acts_as_notifiable :users, targets: User.all, action_cable_api_allowed: true
|
|
120
|
+
# end
|
|
121
|
+
#
|
|
98
122
|
# * :notifiable_path
|
|
99
123
|
# * Path to redirect from open or move action of notification controller.
|
|
100
124
|
# You can also use this notifiable_path as notifiable link in notification view.
|
|
@@ -115,6 +139,8 @@ module ActivityNotification
|
|
|
115
139
|
# Tracked notifications are disabled as default.
|
|
116
140
|
# When you set true as this :tracked option, default callbacks will be enabled for [:create, :update].
|
|
117
141
|
# You can use :only, :except and other notify options as hash for this option.
|
|
142
|
+
# Tracked notifications are generated synchronously as default configuration.
|
|
143
|
+
# You can use :notify_later option as notify options to make tracked notifications generated asynchronously.
|
|
118
144
|
# @example Add all callbacks to generate notifications for creation and update
|
|
119
145
|
# # app/models/comment.rb
|
|
120
146
|
# class Comment < ActiveRecord::Base
|
|
@@ -133,6 +159,12 @@ module ActivityNotification
|
|
|
133
159
|
# belongs_to :article
|
|
134
160
|
# acts_as_notifiable :users, targets: User.all, tracked: { except: [:update], key: "comment.edited", send_later: false }
|
|
135
161
|
# end
|
|
162
|
+
# @example Add callbacks to generate notifications asynchronously for creation only
|
|
163
|
+
# # app/models/comment.rb
|
|
164
|
+
# class Comment < ActiveRecord::Base
|
|
165
|
+
# belongs_to :article
|
|
166
|
+
# acts_as_notifiable :users, targets: User.all, tracked: { only: [:create], notify_later: true }
|
|
167
|
+
# end
|
|
136
168
|
#
|
|
137
169
|
# * :printable_name or :printable_notifiable_name
|
|
138
170
|
# * Printable notifiable name.
|
|
@@ -188,6 +220,7 @@ module ActivityNotification
|
|
|
188
220
|
# @option options [Symbol, Proc, Object] :notifier (nil) Notifier of the notifications
|
|
189
221
|
# @option options [Symbol, Proc, Hash] :parameters ({}) Additional parameters of the notifications
|
|
190
222
|
# @option options [Symbol, Proc, Boolean] :email_allowed (ActivityNotification.config.email_enabled) Whether activity_notification sends notification email
|
|
223
|
+
# @option options [Symbol, Proc, Boolean] :action_cable_allowed (ActivityNotification.config.action_cable_enabled) Whether activity_notification publishes WebSocket using ActionCable
|
|
191
224
|
# @option options [Symbol, Proc, String] :notifiable_path (polymorphic_path(self)) Path to redirect from open or move action of notification controller
|
|
192
225
|
# @option options [Boolean, Hash] :tracked (nil) Flag or parameters for automatic tracked notifications
|
|
193
226
|
# @option options [Symbol, Proc, String] :printable_name (ActivityNotification::Common.printable_name) Printable notifiable name
|
|
@@ -206,6 +239,22 @@ module ActivityNotification
|
|
|
206
239
|
configured_params.update(add_destroy_dependency(target_type, options[:dependent_notifications]))
|
|
207
240
|
end
|
|
208
241
|
|
|
242
|
+
if options[:action_cable_allowed] || (ActivityNotification.config.action_cable_enabled && options[:action_cable_allowed] != false)
|
|
243
|
+
options[:optional_targets] ||= {}
|
|
244
|
+
require 'activity_notification/optional_targets/action_cable_channel'
|
|
245
|
+
unless options[:optional_targets].has_key?(ActivityNotification::OptionalTarget::ActionCableChannel)
|
|
246
|
+
options[:optional_targets][ActivityNotification::OptionalTarget::ActionCableChannel] = {}
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
if options[:action_cable_api_allowed] || (ActivityNotification.config.action_cable_api_enabled && options[:action_cable_api_allowed] != false)
|
|
251
|
+
options[:optional_targets] ||= {}
|
|
252
|
+
require 'activity_notification/optional_targets/action_cable_api_channel'
|
|
253
|
+
unless options[:optional_targets].has_key?(ActivityNotification::OptionalTarget::ActionCableApiChannel)
|
|
254
|
+
options[:optional_targets][ActivityNotification::OptionalTarget::ActionCableApiChannel] = {}
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
|
|
209
258
|
if options[:optional_targets].is_a?(Hash)
|
|
210
259
|
options[:optional_targets] = arrange_optional_targets_option(options[:optional_targets])
|
|
211
260
|
end
|
|
@@ -213,6 +262,7 @@ module ActivityNotification
|
|
|
213
262
|
options[:printable_notifiable_name] ||= options.delete(:printable_name)
|
|
214
263
|
configured_params
|
|
215
264
|
.merge set_acts_as_parameters_for_target(target_type, [:targets, :group, :group_expiry_delay, :parameters, :email_allowed], options, "notification_")
|
|
265
|
+
.merge set_acts_as_parameters_for_target(target_type, [:action_cable_allowed, :action_cable_api_allowed], options, "notifiable_")
|
|
216
266
|
.merge set_acts_as_parameters_for_target(target_type, [:notifier, :notifiable_path, :printable_notifiable_name, :optional_targets], options)
|
|
217
267
|
end
|
|
218
268
|
|
|
@@ -225,6 +275,8 @@ module ActivityNotification
|
|
|
225
275
|
:notifier,
|
|
226
276
|
:parameters,
|
|
227
277
|
:email_allowed,
|
|
278
|
+
:action_cable_allowed,
|
|
279
|
+
:action_cable_api_allowed,
|
|
228
280
|
:notifiable_path,
|
|
229
281
|
:printable_notifiable_name, :printable_name,
|
|
230
282
|
:dependent_notifications,
|
|
@@ -270,7 +322,17 @@ module ActivityNotification
|
|
|
270
322
|
# @param [Symbol] tracked_action Tracked action (:create or :update)
|
|
271
323
|
# @param [Proc] tracked_proc Proc or lambda function to execute
|
|
272
324
|
def add_tracked_callback(tracked_callbacks, tracked_action, tracked_proc)
|
|
273
|
-
|
|
325
|
+
return unless tracked_callbacks.include? tracked_action
|
|
326
|
+
|
|
327
|
+
# FIXME: Avoid Rails issue that after commit callbacks on update does not triggered when optimistic locking is enabled
|
|
328
|
+
# See the followings:
|
|
329
|
+
# https://github.com/rails/rails/issues/30779
|
|
330
|
+
# https://github.com/rails/rails/pull/32167
|
|
331
|
+
|
|
332
|
+
# :nocov:
|
|
333
|
+
if !(Gem::Version.new("5.1.6") <= Rails.gem_version && Rails.gem_version < Gem::Version.new("5.2.2")) && respond_to?(:after_commit)
|
|
334
|
+
after_commit tracked_proc, on: tracked_action
|
|
335
|
+
else
|
|
274
336
|
case tracked_action
|
|
275
337
|
when :create
|
|
276
338
|
after_create tracked_proc
|
|
@@ -278,6 +340,7 @@ module ActivityNotification
|
|
|
278
340
|
after_update tracked_proc
|
|
279
341
|
end
|
|
280
342
|
end
|
|
343
|
+
# :nocov:
|
|
281
344
|
end
|
|
282
345
|
|
|
283
346
|
# Adds destroy dependency.
|
|
@@ -34,10 +34,61 @@ module ActivityNotification
|
|
|
34
34
|
# acts_as_target email: :email, email_allowed: :confirmed_at
|
|
35
35
|
# end
|
|
36
36
|
#
|
|
37
|
+
# * :batch_email_allowed
|
|
38
|
+
# * Whether activity_notification sends batch notification email to this target.
|
|
39
|
+
# Specified method or symbol is expected to return true (not nil) or false (nil).
|
|
40
|
+
# This parameter is a optional since default value is false.
|
|
41
|
+
# To use batch notification email, both of batch_email_allowed and subscription_allowed options must return true (not nil) in target model.
|
|
42
|
+
# This can be also configured default option in initializer.
|
|
43
|
+
# @example Always enable batch email notification for this target
|
|
44
|
+
# # app/models/user.rb
|
|
45
|
+
# class User < ActiveRecord::Base
|
|
46
|
+
# acts_as_target email: :email, batch_email_allowed: true
|
|
47
|
+
# end
|
|
48
|
+
# @example Use confirmed_at of devise field to decide whether activity_notification sends batch notification email to this user
|
|
49
|
+
# # app/models/user.rb
|
|
50
|
+
# class User < ActiveRecord::Base
|
|
51
|
+
# acts_as_target email: :email, batch_email_allowed: :confirmed_at
|
|
52
|
+
# end
|
|
53
|
+
#
|
|
54
|
+
# * :subscription_allowed
|
|
55
|
+
# * Whether activity_notification manages subscriptions of this target.
|
|
56
|
+
# Specified method or symbol is expected to return true (not nil) or false (nil).
|
|
57
|
+
# This parameter is a optional since default value is false.
|
|
58
|
+
# This can be also configured default option in initializer.
|
|
59
|
+
# @example Subscribe notifications for this target
|
|
60
|
+
# # app/models/user.rb
|
|
61
|
+
# class User < ActiveRecord::Base
|
|
62
|
+
# acts_as_target subscription_allowed: true
|
|
63
|
+
# end
|
|
64
|
+
#
|
|
65
|
+
# * :action_cable_allowed
|
|
66
|
+
# * Whether activity_notification publishes WebSocket notifications using ActionCable to this target.
|
|
67
|
+
# Specified method or symbol is expected to return true (not nil) or false (nil).
|
|
68
|
+
# This parameter is a optional since default value is false.
|
|
69
|
+
# To use ActionCable for notifications, action_cable_enabled option must return true (not nil) in both of notifiable and target model.
|
|
70
|
+
# This can be also configured default option in initializer.
|
|
71
|
+
# @example Enable notification ActionCable for this target
|
|
72
|
+
# # app/models/user.rb
|
|
73
|
+
# class User < ActiveRecord::Base
|
|
74
|
+
# acts_as_target action_cable_allowed: true
|
|
75
|
+
# end
|
|
76
|
+
#
|
|
77
|
+
# * :action_cable_with_devise
|
|
78
|
+
# * Whether activity_notification publishes WebSocket notifications using ActionCable only to authenticated target with Devise.
|
|
79
|
+
# Specified method or symbol is expected to return true (not nil) or false (nil).
|
|
80
|
+
# This parameter is a optional since default value is false.
|
|
81
|
+
# To use ActionCable for notifications, also action_cable_enabled option must return true (not nil) in the target model.
|
|
82
|
+
# @example Enable notification ActionCable for this target
|
|
83
|
+
# # app/models/user.rb
|
|
84
|
+
# class User < ActiveRecord::Base
|
|
85
|
+
# acts_as_target action_cable_allowed: true, action_cable_with_devise* true
|
|
86
|
+
# end
|
|
87
|
+
#
|
|
37
88
|
# * :devise_resource
|
|
38
89
|
# * Integrated resource with devise authentication.
|
|
39
90
|
# This parameter is a optional since `self` is used as default value.
|
|
40
|
-
# You also have to configure routing for devise
|
|
91
|
+
# You also have to configure routing for devise in routes.rb
|
|
41
92
|
# @example No :devise_resource is needed when notification target is the same as authenticated resource
|
|
42
93
|
# # config/routes.rb
|
|
43
94
|
# devise_for :users
|
|
@@ -68,6 +119,42 @@ module ActivityNotification
|
|
|
68
119
|
# devise_resource: :user
|
|
69
120
|
# end
|
|
70
121
|
#
|
|
122
|
+
# * :current_devise_target
|
|
123
|
+
# * Current authenticated target by devise authentication.
|
|
124
|
+
# This parameter is a optional since `current_<devise_resource_name>` is used as default value.
|
|
125
|
+
# In addition, this parameter is only needed when :devise_default_route in your route.rb is enabled.
|
|
126
|
+
# You also have to configure routing for devise in routes.rb
|
|
127
|
+
# @example No :current_devise_target is needed when notification target is the same as authenticated resource
|
|
128
|
+
# # config/routes.rb
|
|
129
|
+
# devise_for :users
|
|
130
|
+
# notify_to :users
|
|
131
|
+
#
|
|
132
|
+
# # app/models/user.rb
|
|
133
|
+
# class User < ActiveRecord::Base
|
|
134
|
+
# devise :database_authenticatable, :registerable, :confirmable
|
|
135
|
+
# acts_as_target email: :email, email_allowed: :confirmed_at
|
|
136
|
+
# end
|
|
137
|
+
#
|
|
138
|
+
# @example Send Admin model and use associated User model with devise authentication
|
|
139
|
+
# # config/routes.rb
|
|
140
|
+
# devise_for :users
|
|
141
|
+
# notify_to :admins, with_devise: :users
|
|
142
|
+
#
|
|
143
|
+
# # app/models/user.rb
|
|
144
|
+
# class User < ActiveRecord::Base
|
|
145
|
+
# devise :database_authenticatable, :registerable, :confirmable
|
|
146
|
+
# end
|
|
147
|
+
#
|
|
148
|
+
# # app/models/admin.rb
|
|
149
|
+
# class Admin < ActiveRecord::Base
|
|
150
|
+
# belongs_to :user
|
|
151
|
+
# validates :user, presence: true
|
|
152
|
+
# acts_as_notification_target email: :email,
|
|
153
|
+
# email_allowed: ->(admin, key) { admin.user.confirmed_at.present? },
|
|
154
|
+
# devise_resource: :user,
|
|
155
|
+
# current_devise_target: ->(current_user) { current_user.admin }
|
|
156
|
+
# end
|
|
157
|
+
#
|
|
71
158
|
# * :printable_name or :printable_notification_target_name
|
|
72
159
|
# * Printable notification target name.
|
|
73
160
|
# This parameter is a optional since `ActivityNotification::Common.printable_name` is used as default value.
|
|
@@ -85,19 +172,22 @@ module ActivityNotification
|
|
|
85
172
|
# end
|
|
86
173
|
#
|
|
87
174
|
# @param [Hash] options Options for notifiable model configuration
|
|
88
|
-
# @option options [Symbol, Proc, String] :email
|
|
89
|
-
# @option options [Symbol, Proc, Boolean] :email_allowed
|
|
90
|
-
# @option options [Symbol, Proc, Boolean] :batch_email_allowed
|
|
91
|
-
# @option options [Symbol, Proc, Boolean] :subscription_allowed
|
|
92
|
-
# @option options [Symbol, Proc,
|
|
93
|
-
# @option options [Symbol, Proc,
|
|
175
|
+
# @option options [Symbol, Proc, String] :email (nil) Email address to send notification email
|
|
176
|
+
# @option options [Symbol, Proc, Boolean] :email_allowed (ActivityNotification.config.email_enabled) Whether activity_notification sends notification email to this target
|
|
177
|
+
# @option options [Symbol, Proc, Boolean] :batch_email_allowed (ActivityNotification.config.email_enabled) Whether activity_notification sends batch notification email to this target
|
|
178
|
+
# @option options [Symbol, Proc, Boolean] :subscription_allowed (ActivityNotification.config.subscription_enabled) Whether activity_notification manages subscriptions of this target
|
|
179
|
+
# @option options [Symbol, Proc, Boolean] :action_cable_allowed (ActivityNotification.config.action_cable_enabled) Whether activity_notification publishes WebSocket notifications using ActionCable to this target
|
|
180
|
+
# @option options [Symbol, Proc, Boolean] :action_cable_with_devise (false) Whether activity_notification publishes WebSocket notifications using ActionCable only to authenticated target with Devise
|
|
181
|
+
# @option options [Symbol, Proc, Object] :devise_resource (->(model) { model }) Integrated resource with devise authentication
|
|
182
|
+
# @option options [Symbol, Proc, Object] :current_devise_target (->(current_resource) { current_resource }) Current authenticated target by devise authentication
|
|
183
|
+
# @option options [Symbol, Proc, String] :printable_name (ActivityNotification::Common.printable_name) Printable notification target name
|
|
94
184
|
# @return [Hash] Configured parameters as target model
|
|
95
185
|
def acts_as_target(options = {})
|
|
96
186
|
include Target
|
|
97
187
|
|
|
98
188
|
options[:printable_notification_target_name] ||= options.delete(:printable_name)
|
|
99
189
|
options[:batch_notification_email_allowed] ||= options.delete(:batch_email_allowed)
|
|
100
|
-
acts_as_params = set_acts_as_parameters([:email, :email_allowed, :subscription_allowed, :devise_resource], options, "notification_")
|
|
190
|
+
acts_as_params = set_acts_as_parameters([:email, :email_allowed, :subscription_allowed, :action_cable_allowed, :action_cable_with_devise, :devise_resource, :current_devise_target], options, "notification_")
|
|
101
191
|
.merge set_acts_as_parameters([:batch_notification_email_allowed, :printable_notification_target_name], options)
|
|
102
192
|
include Subscriber if subscription_enabled?
|
|
103
193
|
acts_as_params
|
|
@@ -107,7 +197,7 @@ module ActivityNotification
|
|
|
107
197
|
# Returns array of available target options in acts_as_target.
|
|
108
198
|
# @return [Array<Symbol>] Array of available target options
|
|
109
199
|
def available_target_options
|
|
110
|
-
[:email, :email_allowed, :batch_email_allowed, :subscription_allowed, :devise_resource, :printable_notification_target_name, :printable_name].freeze
|
|
200
|
+
[:email, :email_allowed, :batch_email_allowed, :subscription_allowed, :action_cable_enabled, :action_cable_with_devise, :devise_resource, :printable_notification_target_name, :printable_name].freeze
|
|
111
201
|
end
|
|
112
202
|
end
|
|
113
203
|
end
|
|
@@ -17,6 +17,7 @@ module ActivityNotification
|
|
|
17
17
|
autoload :Config
|
|
18
18
|
autoload :Renderable
|
|
19
19
|
autoload :VERSION
|
|
20
|
+
autoload :GEM_VERSION
|
|
20
21
|
|
|
21
22
|
module Mailers
|
|
22
23
|
autoload :Helpers, 'activity_notification/mailers/helpers'
|
|
@@ -56,13 +57,26 @@ module ActivityNotification
|
|
|
56
57
|
end
|
|
57
58
|
|
|
58
59
|
# Load ActivityNotification helpers
|
|
60
|
+
require 'activity_notification/helpers/errors'
|
|
59
61
|
require 'activity_notification/helpers/polymorphic_helpers'
|
|
60
62
|
require 'activity_notification/helpers/view_helpers'
|
|
61
63
|
require 'activity_notification/controllers/common_controller'
|
|
64
|
+
require 'activity_notification/controllers/common_api_controller'
|
|
62
65
|
require 'activity_notification/controllers/store_controller'
|
|
63
66
|
require 'activity_notification/controllers/devise_authentication_controller'
|
|
64
67
|
require 'activity_notification/optional_targets/base'
|
|
65
68
|
|
|
69
|
+
# Load Swagger API references
|
|
70
|
+
require 'activity_notification/apis/swagger'
|
|
71
|
+
require 'activity_notification/models/concerns/swagger/notification_schema'
|
|
72
|
+
require 'activity_notification/models/concerns/swagger/subscription_schema'
|
|
73
|
+
require 'activity_notification/models/concerns/swagger/error_schema'
|
|
74
|
+
require 'activity_notification/controllers/concerns/swagger/notifications_parameters'
|
|
75
|
+
require 'activity_notification/controllers/concerns/swagger/subscriptions_parameters'
|
|
76
|
+
require 'activity_notification/controllers/concerns/swagger/error_responses'
|
|
77
|
+
require 'activity_notification/controllers/concerns/swagger/notifications_api'
|
|
78
|
+
require 'activity_notification/controllers/concerns/swagger/subscriptions_api'
|
|
79
|
+
|
|
66
80
|
# Load role for models
|
|
67
81
|
require 'activity_notification/models'
|
|
68
82
|
|
|
@@ -6,7 +6,8 @@ module ActivityNotification
|
|
|
6
6
|
# @example Run controller generator for users as target
|
|
7
7
|
# rails generate activity_notification:controllers users
|
|
8
8
|
class ControllersGenerator < Rails::Generators::Base
|
|
9
|
-
CONTROLLERS = ['notifications', 'notifications_with_devise', '
|
|
9
|
+
CONTROLLERS = ['notifications', 'notifications_with_devise', 'notifications_api', 'notifications_api_with_devise',
|
|
10
|
+
'subscriptions', 'subscriptions_with_devise', 'subscriptions_api', 'subscriptions_api_with_devise'].freeze
|
|
10
11
|
|
|
11
12
|
desc <<-DESC.strip_heredoc
|
|
12
13
|
Create inherited ActivityNotification controllers in your app/controllers folder.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
ActivityNotification.configure do |config|
|
|
2
2
|
|
|
3
|
-
# Configure
|
|
4
|
-
# Set
|
|
5
|
-
ENV['AN_ORM'] = 'active_record' unless ENV['AN_ORM'] == 'mongoid'
|
|
6
|
-
config.orm = ENV['AN_ORM']
|
|
7
|
-
|
|
8
|
-
# Configure if all activity notifications are enabled.
|
|
9
|
-
# Set false when you want to turn off activity notifications.
|
|
3
|
+
# Configure if all activity notifications are enabled
|
|
4
|
+
# Set false when you want to turn off activity notifications
|
|
10
5
|
config.enabled = true
|
|
11
6
|
|
|
7
|
+
# Configure ORM name for ActivityNotification.
|
|
8
|
+
# Set :active_record, :mongoid or :dynamoid.
|
|
9
|
+
ENV['AN_ORM'] = 'active_record' if ['mongoid', 'dynamoid'].exclude?(ENV['AN_ORM'])
|
|
10
|
+
config.orm = ENV['AN_ORM'].to_sym
|
|
11
|
+
|
|
12
12
|
# Configure table name to store notification data.
|
|
13
13
|
config.notification_table_name = "notifications"
|
|
14
14
|
|
|
@@ -31,6 +31,16 @@ ActivityNotification.configure do |config|
|
|
|
31
31
|
# Set false when you want to unsubscribe to any notifications as default.
|
|
32
32
|
config.subscribe_as_default = true
|
|
33
33
|
|
|
34
|
+
# Configure default email subscription value to use when the subscription record does not configured.
|
|
35
|
+
# Note that you can configure them for each method calling as default argument.
|
|
36
|
+
# Set false when you want to unsubscribe to email notifications as default.
|
|
37
|
+
# config.subscribe_to_email_as_default = true
|
|
38
|
+
|
|
39
|
+
# Configure default optional target subscription value to use when the subscription record does not configured.
|
|
40
|
+
# Note that you can configure them for each method calling as default argument.
|
|
41
|
+
# Set false when you want to unsubscribe to optinal target notifications as default.
|
|
42
|
+
# config.subscribe_to_optional_targets_as_default = true
|
|
43
|
+
|
|
34
44
|
# Configure the e-mail address which will be shown in ActivityNotification::Mailer,
|
|
35
45
|
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
|
|
36
46
|
config.mailer_sender = 'please-change-me-at-config-initializers-activity_notification@example.com'
|
|
@@ -41,10 +51,54 @@ ActivityNotification.configure do |config|
|
|
|
41
51
|
# Configure the parent class responsible to send e-mails.
|
|
42
52
|
# config.parent_mailer = 'ActionMailer::Base'
|
|
43
53
|
|
|
54
|
+
# Configure the parent job class for delayed notifications.
|
|
55
|
+
# config.parent_job = 'ActiveJob::Base'
|
|
56
|
+
|
|
44
57
|
# Configure the parent class for activity_notification controllers.
|
|
45
58
|
# config.parent_controller = 'ApplicationController'
|
|
46
59
|
|
|
60
|
+
# Configure the parent class for activity_notification channels.
|
|
61
|
+
# config.parent_channel = 'ActionCable::Channel::Base'
|
|
62
|
+
|
|
63
|
+
# Configure the custom mailer templates directory
|
|
64
|
+
# config.mailer_templates_dir = 'activity_notification/mailer'
|
|
65
|
+
|
|
47
66
|
# Configure default limit number of opened notifications you can get from opened* scope
|
|
48
67
|
config.opened_index_limit = 10
|
|
49
68
|
|
|
69
|
+
# Configure ActiveJob queue name for delayed notifications.
|
|
70
|
+
config.active_job_queue = :activity_notification
|
|
71
|
+
|
|
72
|
+
# Configure delimiter of composite key for DynamoDB.
|
|
73
|
+
# config.composite_key_delimiter = '#'
|
|
74
|
+
|
|
75
|
+
# Configure if activity_notification stores notificaion records including associated records like target and notifiable..
|
|
76
|
+
# This store_with_associated_records option can be set true only when you use mongoid or dynamoid ORM.
|
|
77
|
+
config.store_with_associated_records = false
|
|
78
|
+
|
|
79
|
+
# Configure if WebSocket subscription using ActionCable is enabled.
|
|
80
|
+
# Note that you can configure them for each model by acts_as roles.
|
|
81
|
+
# Set true when you want to turn on WebSocket subscription using ActionCable as default.
|
|
82
|
+
config.action_cable_enabled = false
|
|
83
|
+
|
|
84
|
+
# Configure if WebSocket API subscription using ActionCable is enabled.
|
|
85
|
+
# Note that you can configure them for each model by acts_as roles.
|
|
86
|
+
# Set true when you want to turn on WebSocket API subscription using ActionCable as default.
|
|
87
|
+
config.action_cable_api_enabled = false
|
|
88
|
+
|
|
89
|
+
# Configure if activity_notification publishes WebSocket notifications using ActionCable only to authenticated target with Devise.
|
|
90
|
+
# Note that you can configure them for each model by acts_as roles.
|
|
91
|
+
# Set true when you want to use Device integration with WebSocket subscription using ActionCable as default.
|
|
92
|
+
config.action_cable_with_devise = false
|
|
93
|
+
|
|
94
|
+
# Configure notification channel prefix for ActionCable.
|
|
95
|
+
config.notification_channel_prefix = 'activity_notification_channel'
|
|
96
|
+
|
|
97
|
+
# Configure notification API channel prefix for ActionCable.
|
|
98
|
+
config.notification_api_channel_prefix = 'activity_notification_api_channel'
|
|
99
|
+
|
|
100
|
+
# Configure if activity_notification internally rescues optional target errors. Default value is true.
|
|
101
|
+
# See https://github.com/simukappu/activity_notification/issues/155 for more details.
|
|
102
|
+
config.rescue_optional_target_errors = true
|
|
103
|
+
|
|
50
104
|
end
|
|
@@ -6,8 +6,8 @@ Some setup you must do manually if you haven't yet:
|
|
|
6
6
|
For example:
|
|
7
7
|
|
|
8
8
|
Rails.application.routes.draw do
|
|
9
|
-
notify_to :users,
|
|
10
|
-
notify_to :admins, with_devise: :users,
|
|
9
|
+
notify_to :users, controller: 'users/notifications'
|
|
10
|
+
notify_to :admins, with_devise: :users, controller: 'admins/notifications_with_devise'
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
===============================================================================
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class <%= @target_prefix %>NotificationsController < ActivityNotification::NotificationsController
|
|
2
|
+
# GET /:target_type/:target_id/notifications
|
|
3
|
+
# def index
|
|
4
|
+
# super
|
|
5
|
+
# end
|
|
6
|
+
|
|
7
|
+
# POST /:target_type/:target_id/notifications/open_all
|
|
8
|
+
# def open_all
|
|
9
|
+
# super
|
|
10
|
+
# end
|
|
11
|
+
|
|
12
|
+
# GET /:target_type/:target_id/notifications/:id
|
|
13
|
+
# def show
|
|
14
|
+
# super
|
|
15
|
+
# end
|
|
16
|
+
|
|
17
|
+
# DELETE /:target_type/:target_id/notifications/:id
|
|
18
|
+
# def destroy
|
|
19
|
+
# super
|
|
20
|
+
# end
|
|
21
|
+
|
|
22
|
+
# PUT /:target_type/:target_id/notifications/:id/open
|
|
23
|
+
# def open
|
|
24
|
+
# super
|
|
25
|
+
# end
|
|
26
|
+
|
|
27
|
+
# GET /:target_type/:target_id/notifications/:id/move
|
|
28
|
+
# def move
|
|
29
|
+
# super
|
|
30
|
+
# end
|
|
31
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class <%= @target_prefix %>NotificationsWithDeviseController < ActivityNotification::NotificationsWithDeviseController
|
|
2
|
+
# GET /:target_type/:target_id/notifications
|
|
3
|
+
# def index
|
|
4
|
+
# super
|
|
5
|
+
# end
|
|
6
|
+
|
|
7
|
+
# POST /:target_type/:target_id/notifications/open_all
|
|
8
|
+
# def open_all
|
|
9
|
+
# super
|
|
10
|
+
# end
|
|
11
|
+
|
|
12
|
+
# GET /:target_type/:target_id/notifications/:id
|
|
13
|
+
# def show
|
|
14
|
+
# super
|
|
15
|
+
# end
|
|
16
|
+
|
|
17
|
+
# DELETE /:target_type/:target_id/notifications/:id
|
|
18
|
+
# def destroy
|
|
19
|
+
# super
|
|
20
|
+
# end
|
|
21
|
+
|
|
22
|
+
# PUT /:target_type/:target_id/notifications/:id/open
|
|
23
|
+
# def open
|
|
24
|
+
# super
|
|
25
|
+
# end
|
|
26
|
+
|
|
27
|
+
# GET /:target_type/:target_id/notifications/:id/move
|
|
28
|
+
# def move
|
|
29
|
+
# super
|
|
30
|
+
# end
|
|
31
|
+
end
|
|
@@ -19,7 +19,7 @@ class <%= @target_prefix %>NotificationsController < ActivityNotification::Notif
|
|
|
19
19
|
# super
|
|
20
20
|
# end
|
|
21
21
|
|
|
22
|
-
#
|
|
22
|
+
# PUT /:target_type/:target_id/notifications/:id/open
|
|
23
23
|
# def open
|
|
24
24
|
# super
|
|
25
25
|
# end
|
|
@@ -28,40 +28,4 @@ class <%= @target_prefix %>NotificationsController < ActivityNotification::Notif
|
|
|
28
28
|
# def move
|
|
29
29
|
# super
|
|
30
30
|
# end
|
|
31
|
-
|
|
32
|
-
# No action routing
|
|
33
|
-
# This method needs to be public since it is called from view helper
|
|
34
|
-
# def target_view_path
|
|
35
|
-
# super
|
|
36
|
-
# end
|
|
37
|
-
|
|
38
|
-
# protected
|
|
39
|
-
|
|
40
|
-
# def set_target
|
|
41
|
-
# super
|
|
42
|
-
# end
|
|
43
|
-
|
|
44
|
-
# def set_notification
|
|
45
|
-
# super
|
|
46
|
-
# end
|
|
47
|
-
|
|
48
|
-
# def set_index_options
|
|
49
|
-
# super
|
|
50
|
-
# end
|
|
51
|
-
|
|
52
|
-
# def load_index
|
|
53
|
-
# super
|
|
54
|
-
# end
|
|
55
|
-
|
|
56
|
-
# def controller_path
|
|
57
|
-
# super
|
|
58
|
-
# end
|
|
59
|
-
|
|
60
|
-
# def set_view_prefixes
|
|
61
|
-
# super
|
|
62
|
-
# end
|
|
63
|
-
|
|
64
|
-
# def return_back_or_ajax
|
|
65
|
-
# super
|
|
66
|
-
# end
|
|
67
31
|
end
|
|
@@ -19,7 +19,7 @@ class <%= @target_prefix %>NotificationsWithDeviseController < ActivityNotificat
|
|
|
19
19
|
# super
|
|
20
20
|
# end
|
|
21
21
|
|
|
22
|
-
#
|
|
22
|
+
# PUT /:target_type/:target_id/notifications/:id/open
|
|
23
23
|
# def open
|
|
24
24
|
# super
|
|
25
25
|
# end
|
|
@@ -28,48 +28,4 @@ class <%= @target_prefix %>NotificationsWithDeviseController < ActivityNotificat
|
|
|
28
28
|
# def move
|
|
29
29
|
# super
|
|
30
30
|
# end
|
|
31
|
-
|
|
32
|
-
# No action routing
|
|
33
|
-
# This method needs to be public since it is called from view helper
|
|
34
|
-
# def target_view_path
|
|
35
|
-
# super
|
|
36
|
-
# end
|
|
37
|
-
|
|
38
|
-
# protected
|
|
39
|
-
|
|
40
|
-
# def set_target
|
|
41
|
-
# super
|
|
42
|
-
# end
|
|
43
|
-
|
|
44
|
-
# def set_notification
|
|
45
|
-
# super
|
|
46
|
-
# end
|
|
47
|
-
|
|
48
|
-
# def set_index_options
|
|
49
|
-
# super
|
|
50
|
-
# end
|
|
51
|
-
|
|
52
|
-
# def load_index
|
|
53
|
-
# super
|
|
54
|
-
# end
|
|
55
|
-
|
|
56
|
-
# def controller_path
|
|
57
|
-
# super
|
|
58
|
-
# end
|
|
59
|
-
|
|
60
|
-
# def set_view_prefixes
|
|
61
|
-
# super
|
|
62
|
-
# end
|
|
63
|
-
|
|
64
|
-
# def return_back_or_ajax
|
|
65
|
-
# super
|
|
66
|
-
# end
|
|
67
|
-
|
|
68
|
-
# def authenticate_devise_resource!
|
|
69
|
-
# super
|
|
70
|
-
# end
|
|
71
|
-
|
|
72
|
-
# def authenticate_target!
|
|
73
|
-
# super
|
|
74
|
-
# end
|
|
75
31
|
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
class <%= @target_prefix %>SubscriptionsController < ActivityNotification::SubscriptionsController
|
|
2
|
+
# GET /:target_type/:target_id/subscriptions
|
|
3
|
+
# def index
|
|
4
|
+
# super
|
|
5
|
+
# end
|
|
6
|
+
|
|
7
|
+
# PUT /:target_type/:target_id/subscriptions
|
|
8
|
+
# def create
|
|
9
|
+
# super
|
|
10
|
+
# end
|
|
11
|
+
|
|
12
|
+
# GET /:target_type/:target_id/subscriptions/find
|
|
13
|
+
def find
|
|
14
|
+
super
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# GET /:target_type/:target_id/subscriptions/optional_target_names
|
|
18
|
+
def optional_target_names
|
|
19
|
+
super
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# GET /:target_type/:target_id/subscriptions/:id
|
|
23
|
+
# def show
|
|
24
|
+
# super
|
|
25
|
+
# end
|
|
26
|
+
|
|
27
|
+
# DELETE /:target_type/:target_id/subscriptions/:id
|
|
28
|
+
# def destroy
|
|
29
|
+
# super
|
|
30
|
+
# end
|
|
31
|
+
|
|
32
|
+
# PUT /:target_type/:target_id/subscriptions/:id/subscribe
|
|
33
|
+
# def subscribe
|
|
34
|
+
# super
|
|
35
|
+
# end
|
|
36
|
+
|
|
37
|
+
# PUT /:target_type/:target_id/subscriptions/:id/unsubscribe
|
|
38
|
+
# def unsubscribe
|
|
39
|
+
# super
|
|
40
|
+
# end
|
|
41
|
+
|
|
42
|
+
# PUT /:target_type/:target_id/subscriptions/:id/subscribe_to_email
|
|
43
|
+
# def subscribe_to_email
|
|
44
|
+
# super
|
|
45
|
+
# end
|
|
46
|
+
|
|
47
|
+
# PUT /:target_type/:target_id/subscriptions/:id/unsubscribe_to_email
|
|
48
|
+
# def unsubscribe_to_email
|
|
49
|
+
# super
|
|
50
|
+
# end
|
|
51
|
+
|
|
52
|
+
# PUT /:target_type/:target_id/subscriptions/:id/subscribe_to_optional_target
|
|
53
|
+
# def subscribe_to_optional_target
|
|
54
|
+
# super
|
|
55
|
+
# end
|
|
56
|
+
|
|
57
|
+
# PUT /:target_type/:target_id/subscriptions/:id/unsubscribe_to_optional_target
|
|
58
|
+
# def unsubscribe_to_optional_target
|
|
59
|
+
# super
|
|
60
|
+
# end
|
|
61
|
+
end
|