activity_notification 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.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/.gitignore +10 -3
- data/.travis.yml +6 -5
- data/CHANGELOG.md +22 -0
- data/Gemfile +8 -2
- data/Procfile +1 -1
- data/README.md +153 -1510
- data/activity_notification.gemspec +4 -1
- 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 +1 -1
- data/app/channels/activity_notification/notification_with_devise_channel.rb +1 -1
- 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 +79 -53
- 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 +78 -69
- data/app/views/activity_notification/notifications/default/_default.html.erb +18 -18
- data/app/views/activity_notification/notifications/default/_default_without_grouping.html.erb +14 -14
- data/app/views/activity_notification/notifications/default/index.html.erb +6 -6
- data/app/views/activity_notification/optional_targets/default/action_cable_channel/_default.html.erb +176 -0
- data/app/views/activity_notification/subscriptions/default/_form.html.erb +1 -1
- data/app/views/activity_notification/subscriptions/default/_notification_keys.html.erb +3 -31
- data/app/views/activity_notification/subscriptions/default/_subscription.html.erb +7 -7
- data/app/views/activity_notification/subscriptions/default/index.html.erb +11 -7
- data/bin/deploy_on_heroku.sh +3 -1
- data/docs/CODE_OF_CONDUCT.md +76 -0
- data/docs/CONTRIBUTING.md +36 -0
- data/docs/Functions.md +1130 -0
- data/docs/Setup.md +674 -0
- data/docs/Testing.md +148 -0
- data/gemfiles/Gemfile.rails-4.2 +3 -0
- data/gemfiles/Gemfile.rails-5.0 +3 -0
- data/gemfiles/Gemfile.rails-5.1 +3 -0
- data/gemfiles/Gemfile.rails-5.2 +3 -0
- data/gemfiles/{Gemfile.rails-6.0.rc → Gemfile.rails-6.0} +5 -3
- data/lib/activity_notification.rb +13 -1
- data/lib/activity_notification/apis/notification_api.rb +29 -92
- data/lib/activity_notification/apis/subscription_api.rb +20 -8
- data/lib/activity_notification/apis/swagger.rb +6 -0
- data/lib/activity_notification/config.rb +41 -21
- data/lib/activity_notification/controllers/common_api_controller.rb +30 -0
- data/lib/activity_notification/controllers/common_controller.rb +44 -20
- 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 +7 -6
- data/lib/activity_notification/gem_version.rb +14 -0
- data/lib/activity_notification/helpers/errors.rb +2 -0
- data/lib/activity_notification/helpers/view_helpers.rb +4 -0
- data/lib/activity_notification/mailers/helpers.rb +17 -10
- data/lib/activity_notification/models/concerns/notifiable.rb +26 -10
- data/lib/activity_notification/models/concerns/subscriber.rb +12 -1
- 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 +36 -10
- data/lib/activity_notification/models/notification.rb +1 -0
- data/lib/activity_notification/models/subscription.rb +1 -0
- 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 +7 -13
- data/lib/activity_notification/orm/active_record/notification.rb +17 -1
- data/lib/activity_notification/orm/active_record/subscription.rb +1 -1
- data/lib/activity_notification/orm/dynamoid.rb +28 -0
- data/lib/activity_notification/orm/dynamoid/extension.rb +79 -1
- data/lib/activity_notification/orm/dynamoid/notification.rb +1 -1
- data/lib/activity_notification/orm/dynamoid/subscription.rb +1 -1
- data/lib/activity_notification/orm/mongoid.rb +22 -0
- data/lib/activity_notification/orm/mongoid/notification.rb +17 -1
- data/lib/activity_notification/orm/mongoid/subscription.rb +1 -1
- data/lib/activity_notification/rails/routes.rb +132 -48
- data/lib/activity_notification/renderable.rb +13 -2
- data/lib/activity_notification/roles/acts_as_notifiable.rb +38 -20
- data/lib/activity_notification/version.rb +1 -1
- data/lib/generators/activity_notification/controllers_generator.rb +2 -1
- data/lib/generators/templates/activity_notification.rb +8 -0
- 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/models/README +8 -4
- data/lib/generators/templates/models/notification.rb +1 -1
- data/lib/generators/templates/models/subscription.rb +1 -1
- data/package.json +8 -0
- data/spec/channels/notification_api_channel_shared_examples.rb +59 -0
- data/spec/channels/notification_api_channel_spec.rb +51 -0
- data/spec/channels/notification_api_with_devise_channel_spec.rb +78 -0
- data/spec/concerns/apis/notification_api_spec.rb +37 -2
- data/spec/concerns/models/notifiable_spec.rb +64 -0
- data/spec/concerns/models/subscriber_spec.rb +13 -16
- data/spec/concerns/models/target_spec.rb +32 -0
- data/spec/concerns/renderable_spec.rb +2 -2
- data/spec/controllers/controller_spec_utility.rb +136 -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 +54 -79
- data/spec/controllers/notifications_controller_spec.rb +1 -2
- data/spec/controllers/notifications_with_devise_controller_spec.rb +3 -12
- 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 +94 -121
- data/spec/controllers/subscriptions_controller_spec.rb +1 -2
- data/spec/controllers/subscriptions_with_devise_controller_spec.rb +3 -12
- data/spec/helpers/view_helpers_spec.rb +4 -11
- data/spec/mailers/mailer_spec.rb +41 -0
- data/spec/models/notification_spec.rb +17 -0
- data/spec/models/subscription_spec.rb +0 -13
- data/spec/optional_targets/action_cable_api_channel_spec.rb +37 -0
- data/spec/optional_targets/action_cable_channel_spec.rb +44 -0
- data/spec/optional_targets/amazon_sns_spec.rb +0 -2
- data/spec/optional_targets/slack_spec.rb +0 -2
- data/spec/rails_app/Rakefile +9 -0
- data/spec/rails_app/app/assets/config/manifest.js +3 -0
- data/spec/rails_app/app/assets/images/.keep +0 -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 -3
- 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 +21 -0
- data/spec/rails_app/app/javascript/App.vue +104 -0
- data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +83 -0
- data/spec/rails_app/app/javascript/components/Top.vue +99 -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 +11 -0
- data/spec/rails_app/app/javascript/store/auth.js +37 -0
- data/spec/rails_app/app/models/admin.rb +16 -15
- data/spec/rails_app/app/models/article.rb +26 -21
- data/spec/rails_app/app/models/comment.rb +24 -71
- data/spec/rails_app/app/models/user.rb +43 -20
- data/spec/rails_app/app/views/activity_notification/notifications/default/article/_update.html.erb +146 -0
- data/spec/rails_app/app/views/articles/index.html.erb +51 -7
- data/spec/rails_app/app/views/articles/show.html.erb +1 -1
- data/spec/rails_app/app/views/layouts/_header.html.erb +8 -10
- 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 +15 -2
- data/spec/rails_app/config/environment.rb +2 -1
- data/spec/rails_app/config/environments/development.rb +5 -0
- data/spec/rails_app/config/environments/production.rb +3 -0
- data/spec/rails_app/config/environments/test.rb +5 -0
- data/spec/rails_app/config/initializers/activity_notification.rb +8 -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 +2 -2
- data/spec/rails_app/config/routes.rb +33 -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/20191201000000_add_tokens_to_users.rb +10 -0
- data/spec/rails_app/db/schema.rb +4 -1
- data/spec/rails_app/db/seeds.rb +1 -0
- data/spec/rails_app/lib/custom_optional_targets/raise_error.rb +14 -0
- 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 +1 -3
- data/spec/roles/acts_as_notifier_spec.rb +0 -2
- data/spec/roles/acts_as_target_spec.rb +0 -4
- data/spec/spec_helper.rb +7 -15
- data/spec/version_spec.rb +31 -0
- metadata +187 -13
|
@@ -143,6 +143,8 @@ module ActivityNotification
|
|
|
143
143
|
# @option params [String] :layout (nil) Layout template name
|
|
144
144
|
# @option params [String] :layout_root ('layouts') Root path of layout template
|
|
145
145
|
# @option params [String, Symbol] :fallback (nil) Fallback template to use when MissingTemplate is raised. Set :text to use i18n text as fallback.
|
|
146
|
+
# @option params [Hash] :assigns Parameters to be set as assigns
|
|
147
|
+
# @option params [Hash] :locals Parameters to be set as locals
|
|
146
148
|
# @option params [Hash] others Parameters to be set as locals
|
|
147
149
|
# @return [String] Rendered view or text as string
|
|
148
150
|
def render(context, params = {})
|
|
@@ -150,16 +152,17 @@ module ActivityNotification
|
|
|
150
152
|
|
|
151
153
|
partial = partial_path(*params.values_at(:partial, :partial_root, :target))
|
|
152
154
|
layout = layout_path(*params.values_at(:layout, :layout_root))
|
|
155
|
+
assigns = prepare_assigns(params)
|
|
153
156
|
locals = prepare_locals(params)
|
|
154
157
|
|
|
155
158
|
begin
|
|
156
|
-
context.render params.merge(partial: partial, layout: layout, locals: locals)
|
|
159
|
+
context.render params.merge(partial: partial, layout: layout, assigns: assigns, locals: locals)
|
|
157
160
|
rescue ActionView::MissingTemplate => e
|
|
158
161
|
if params[:fallback] == :text
|
|
159
162
|
context.render plain: self.text(params)
|
|
160
163
|
elsif params[:fallback].present?
|
|
161
164
|
partial = partial_path(*params.values_at(:fallback, :partial_root, :target))
|
|
162
|
-
context.render params.merge(partial: partial, layout: layout, locals: locals)
|
|
165
|
+
context.render params.merge(partial: partial, layout: layout, assigns: assigns, locals: locals)
|
|
163
166
|
else
|
|
164
167
|
raise e
|
|
165
168
|
end
|
|
@@ -196,6 +199,14 @@ module ActivityNotification
|
|
|
196
199
|
select_path(path, root)
|
|
197
200
|
end
|
|
198
201
|
|
|
202
|
+
# Returns assigns parameter for view
|
|
203
|
+
#
|
|
204
|
+
# @param [Hash] params Parameters to add parameters at assigns
|
|
205
|
+
# @return [Hash] assigns parameter
|
|
206
|
+
def prepare_assigns(params)
|
|
207
|
+
params.delete(:assigns) || {}
|
|
208
|
+
end
|
|
209
|
+
|
|
199
210
|
# Returns locals parameter for view
|
|
200
211
|
# There are three variables to be add by method:
|
|
201
212
|
# * notification
|
|
@@ -99,14 +99,26 @@ module ActivityNotification
|
|
|
99
99
|
# * Whether activity_notification publishes notifications to ActionCable channel.
|
|
100
100
|
# Specified method or symbol is expected to return true (not nil) or false (nil).
|
|
101
101
|
# This parameter is a optional since default value is false.
|
|
102
|
-
# To use ActionCable for notifications, action_cable_allowed option must return true (not nil)
|
|
103
|
-
# This can be also configured default option in initializer.
|
|
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
104
|
# @example Enable notification ActionCable for this notifiable model
|
|
105
105
|
# # app/models/comment.rb
|
|
106
106
|
# class Comment < ActiveRecord::Base
|
|
107
107
|
# acts_as_notifiable :users, targets: User.all, action_cable_allowed: true
|
|
108
108
|
# end
|
|
109
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
|
+
#
|
|
110
122
|
# * :notifiable_path
|
|
111
123
|
# * Path to redirect from open or move action of notification controller.
|
|
112
124
|
# You can also use this notifiable_path as notifiable link in notification view.
|
|
@@ -227,13 +239,33 @@ module ActivityNotification
|
|
|
227
239
|
configured_params.update(add_destroy_dependency(target_type, options[:dependent_notifications]))
|
|
228
240
|
end
|
|
229
241
|
|
|
242
|
+
# :nocov:
|
|
243
|
+
if Rails::VERSION::MAJOR >= 5
|
|
244
|
+
if options[:action_cable_allowed] || (ActivityNotification.config.action_cable_enabled && options[:action_cable_allowed] != false)
|
|
245
|
+
options[:optional_targets] ||= {}
|
|
246
|
+
require 'activity_notification/optional_targets/action_cable_channel'
|
|
247
|
+
unless options[:optional_targets].has_key?(ActivityNotification::OptionalTarget::ActionCableChannel)
|
|
248
|
+
options[:optional_targets][ActivityNotification::OptionalTarget::ActionCableChannel] = {}
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
if options[:action_cable_api_allowed] || (ActivityNotification.config.action_cable_api_enabled && options[:action_cable_api_allowed] != false)
|
|
253
|
+
options[:optional_targets] ||= {}
|
|
254
|
+
require 'activity_notification/optional_targets/action_cable_api_channel'
|
|
255
|
+
unless options[:optional_targets].has_key?(ActivityNotification::OptionalTarget::ActionCableApiChannel)
|
|
256
|
+
options[:optional_targets][ActivityNotification::OptionalTarget::ActionCableApiChannel] = {}
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
# :nocov:
|
|
261
|
+
|
|
230
262
|
if options[:optional_targets].is_a?(Hash)
|
|
231
263
|
options[:optional_targets] = arrange_optional_targets_option(options[:optional_targets])
|
|
232
264
|
end
|
|
233
265
|
|
|
234
266
|
options[:printable_notifiable_name] ||= options.delete(:printable_name)
|
|
235
267
|
configured_params
|
|
236
|
-
.merge set_acts_as_parameters_for_target(target_type, [:targets, :group, :group_expiry_delay, :parameters, :email_allowed, :action_cable_allowed], options, "notification_")
|
|
268
|
+
.merge set_acts_as_parameters_for_target(target_type, [:targets, :group, :group_expiry_delay, :parameters, :email_allowed, :action_cable_allowed, :action_cable_api_allowed], options, "notification_")
|
|
237
269
|
.merge set_acts_as_parameters_for_target(target_type, [:notifier, :notifiable_path, :printable_notifiable_name, :optional_targets], options)
|
|
238
270
|
end
|
|
239
271
|
|
|
@@ -247,6 +279,7 @@ module ActivityNotification
|
|
|
247
279
|
:parameters,
|
|
248
280
|
:email_allowed,
|
|
249
281
|
:action_cable_allowed,
|
|
282
|
+
:action_cable_api_allowed,
|
|
250
283
|
:notifiable_path,
|
|
251
284
|
:printable_notifiable_name, :printable_name,
|
|
252
285
|
:dependent_notifications,
|
|
@@ -299,21 +332,9 @@ module ActivityNotification
|
|
|
299
332
|
# https://github.com/rails/rails/issues/30779
|
|
300
333
|
# https://github.com/rails/rails/pull/32167
|
|
301
334
|
|
|
302
|
-
# :
|
|
303
|
-
# :only-rails5-plus#only-rails-without-callback-issue#except-dynamoid:
|
|
304
|
-
# :except-rails5-plus#only-rails-without-callback-issue:
|
|
305
|
-
# :except-rails5-plus#only-rails-without-callback-issue#except-dynamoid:
|
|
335
|
+
# :nocov:
|
|
306
336
|
if !(Gem::Version.new("5.1.6") <= Rails.gem_version && Rails.gem_version < Gem::Version.new("5.2.2")) && respond_to?(:after_commit)
|
|
307
337
|
after_commit tracked_proc, on: tracked_action
|
|
308
|
-
# :only-rails5-plus#only-rails-without-callback-issue:
|
|
309
|
-
# :only-rails5-plus#only-rails-without-callback-issue#except-dynamoid:
|
|
310
|
-
# :except-rails5-plus#only-rails-without-callback-issue:
|
|
311
|
-
# :except-rails5-plus#only-rails-without-callback-issue#except-dynamoid:
|
|
312
|
-
|
|
313
|
-
# :only-rails5-plus#only-rails-with-callback-issue:
|
|
314
|
-
# :only-rails5-plus#only-rails-with-callback-issue#except-dynamoid:
|
|
315
|
-
# :except-rails5-plus#only-rails-with-callback-issue:
|
|
316
|
-
# :except-rails5-plus#only-rails-with-callback-issue#except-dynamoid:
|
|
317
338
|
else
|
|
318
339
|
case tracked_action
|
|
319
340
|
when :create
|
|
@@ -322,10 +343,7 @@ module ActivityNotification
|
|
|
322
343
|
after_update tracked_proc
|
|
323
344
|
end
|
|
324
345
|
end
|
|
325
|
-
# :
|
|
326
|
-
# :only-rails5-plus#only-rails-with-callback-issue#except-dynamoid:
|
|
327
|
-
# :except-rails5-plus#only-rails-with-callback-issue:
|
|
328
|
-
# :except-rails5-plus#only-rails-with-callback-issue#except-dynamoid:
|
|
346
|
+
# :nocov:
|
|
329
347
|
end
|
|
330
348
|
|
|
331
349
|
# Adds destroy dependency.
|
|
@@ -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.
|
|
@@ -71,6 +71,11 @@ ActivityNotification.configure do |config|
|
|
|
71
71
|
# Set true when you want to turn on WebSocket subscription using ActionCable as default.
|
|
72
72
|
config.action_cable_enabled = false
|
|
73
73
|
|
|
74
|
+
# Configure if WebSocket API subscription using ActionCable is enabled.
|
|
75
|
+
# Note that you can configure them for each model by acts_as roles.
|
|
76
|
+
# Set true when you want to turn on WebSocket API subscription using ActionCable as default.
|
|
77
|
+
config.action_cable_api_enabled = false
|
|
78
|
+
|
|
74
79
|
# Configure if ctivity_notification publishes WebSocket notifications using ActionCable only to authenticated target with Devise.
|
|
75
80
|
# Note that you can configure them for each model by acts_as roles.
|
|
76
81
|
# Set true when you want to use Device integration with WebSocket subscription using ActionCable as default.
|
|
@@ -79,4 +84,7 @@ ActivityNotification.configure do |config|
|
|
|
79
84
|
# Configure notification channel prefix for ActionCable.
|
|
80
85
|
config.notification_channel_prefix = 'activity_notification_channel'
|
|
81
86
|
|
|
87
|
+
# Configure notification API channel prefix for ActionCable.
|
|
88
|
+
config.notification_api_channel_prefix = 'activity_notification_api_channel'
|
|
89
|
+
|
|
82
90
|
end
|
|
@@ -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
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
class <%= @target_prefix %>SubscriptionsWithDeviseController < ActivityNotification::SubscriptionsWithDeviseController
|
|
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
|