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
|
@@ -13,12 +13,14 @@ module ActivityNotification
|
|
|
13
13
|
# @option options [String] :layout (nil) Layout template name
|
|
14
14
|
# @option options [String] :layout_root ('layouts') Root path of layout template
|
|
15
15
|
# @option options [String, Symbol] :fallback (nil) Fallback template to use when MissingTemplate is raised. Set :text to use i18n text as fallback.
|
|
16
|
+
# @option options [Hash] :assigns (nil) Parameters to be set as assigns
|
|
17
|
+
# @option options [Hash] :locals (nil) Parameters to be set as locals
|
|
16
18
|
# @return [String] Rendered view or text as string
|
|
17
19
|
def render_notification(notifications, options = {})
|
|
18
20
|
if notifications.is_a? ActivityNotification::Notification
|
|
19
21
|
notifications.render self, options
|
|
20
22
|
elsif notifications.respond_to?(:map)
|
|
21
|
-
return nil if notifications.empty?
|
|
23
|
+
return nil if (notifications.respond_to?(:empty?) ? notifications.empty? : notifications.to_a.empty?)
|
|
22
24
|
notifications.map {|notification| notification.render self, options.dup }.join.html_safe
|
|
23
25
|
end
|
|
24
26
|
end
|
|
@@ -40,6 +42,8 @@ module ActivityNotification
|
|
|
40
42
|
# @option options [String] :notification_layout (nil) Layout template name of the notification index content
|
|
41
43
|
# @option options [String] :fallback (nil) Fallback template to use when MissingTemplate is raised. Set :text to use i18n text as fallback.
|
|
42
44
|
# @option options [String] :partial ('index') Partial template name of the partial index
|
|
45
|
+
# @option options [String] :routing_scope (nil) Routing scope for notification and subscription routes
|
|
46
|
+
# @option options [Boolean] :devise_default_routes (false) If links in default views will be handles as devise default routes
|
|
43
47
|
# @option options [String] :layout (nil) Layout template name of the partial index
|
|
44
48
|
# @option options [Integer] :limit (nil) Limit to query for notifications
|
|
45
49
|
# @option options [Boolean] :reverse (false) If notification index will be ordered as earliest first
|
|
@@ -49,9 +53,11 @@ module ActivityNotification
|
|
|
49
53
|
# @option options [String] :filtered_by_group_type (nil) Group type for filter, valid with :filtered_by_group_id
|
|
50
54
|
# @option options [String] :filtered_by_group_id (nil) Group instance id for filter, valid with :filtered_by_group_type
|
|
51
55
|
# @option options [String] :filtered_by_key (nil) Key of the notification for filter
|
|
56
|
+
# @option options [String] :later_than (nil) ISO 8601 format time to filter notification index later than specified time
|
|
57
|
+
# @option options [String] :earlier_than (nil) ISO 8601 format time to filter notification index earlier than specified time
|
|
52
58
|
# @option options [Array] :custom_filter (nil) Custom notification filter (e.g. ["created_at >= ?", time.hour.ago])
|
|
53
59
|
# @return [String] Rendered view or text as string
|
|
54
|
-
def render_notification_of
|
|
60
|
+
def render_notification_of(target, options = {})
|
|
55
61
|
return unless target.is_a? ActivityNotification::Target
|
|
56
62
|
|
|
57
63
|
# Prepare content for notifications index
|
|
@@ -77,7 +83,10 @@ module ActivityNotification
|
|
|
77
83
|
# @todo Needs any other better implementation
|
|
78
84
|
# @todo Must handle devise namespace
|
|
79
85
|
def notifications_path_for(target, params = {})
|
|
80
|
-
|
|
86
|
+
options = params.dup
|
|
87
|
+
options.delete(:devise_default_routes) ?
|
|
88
|
+
send("#{routing_scope(options)}notifications_path", options) :
|
|
89
|
+
send("#{routing_scope(options)}#{target.to_resource_name}_notifications_path", target, options)
|
|
81
90
|
end
|
|
82
91
|
|
|
83
92
|
# Returns notification_path for the notification
|
|
@@ -88,7 +97,10 @@ module ActivityNotification
|
|
|
88
97
|
# @todo Needs any other better implementation
|
|
89
98
|
# @todo Must handle devise namespace
|
|
90
99
|
def notification_path_for(notification, params = {})
|
|
91
|
-
|
|
100
|
+
options = params.dup
|
|
101
|
+
options.delete(:devise_default_routes) ?
|
|
102
|
+
send("#{routing_scope(options)}notification_path", notification, options) :
|
|
103
|
+
send("#{routing_scope(options)}#{notification.target.to_resource_name}_notification_path", notification.target, notification, options)
|
|
92
104
|
end
|
|
93
105
|
|
|
94
106
|
# Returns move_notification_path for the target of specified notification
|
|
@@ -99,7 +111,10 @@ module ActivityNotification
|
|
|
99
111
|
# @todo Needs any other better implementation
|
|
100
112
|
# @todo Must handle devise namespace
|
|
101
113
|
def move_notification_path_for(notification, params = {})
|
|
102
|
-
|
|
114
|
+
options = params.dup
|
|
115
|
+
options.delete(:devise_default_routes) ?
|
|
116
|
+
send("move_#{routing_scope(options)}notification_path", notification, options) :
|
|
117
|
+
send("move_#{routing_scope(options)}#{notification.target.to_resource_name}_notification_path", notification.target, notification, options)
|
|
103
118
|
end
|
|
104
119
|
|
|
105
120
|
# Returns open_notification_path for the target of specified notification
|
|
@@ -110,7 +125,10 @@ module ActivityNotification
|
|
|
110
125
|
# @todo Needs any other better implementation
|
|
111
126
|
# @todo Must handle devise namespace
|
|
112
127
|
def open_notification_path_for(notification, params = {})
|
|
113
|
-
|
|
128
|
+
options = params.dup
|
|
129
|
+
options.delete(:devise_default_routes) ?
|
|
130
|
+
send("open_#{routing_scope(options)}notification_path", notification, options) :
|
|
131
|
+
send("open_#{routing_scope(options)}#{notification.target.to_resource_name}_notification_path", notification.target, notification, options)
|
|
114
132
|
end
|
|
115
133
|
|
|
116
134
|
# Returns open_all_notifications_path for the target
|
|
@@ -121,7 +139,10 @@ module ActivityNotification
|
|
|
121
139
|
# @todo Needs any other better implementation
|
|
122
140
|
# @todo Must handle devise namespace
|
|
123
141
|
def open_all_notifications_path_for(target, params = {})
|
|
124
|
-
|
|
142
|
+
options = params.dup
|
|
143
|
+
options.delete(:devise_default_routes) ?
|
|
144
|
+
send("open_all_#{routing_scope(options)}notifications_path", options) :
|
|
145
|
+
send("open_all_#{routing_scope(options)}#{target.to_resource_name}_notifications_path", target, options)
|
|
125
146
|
end
|
|
126
147
|
|
|
127
148
|
# Returns notifications_url for the target
|
|
@@ -132,7 +153,10 @@ module ActivityNotification
|
|
|
132
153
|
# @todo Needs any other better implementation
|
|
133
154
|
# @todo Must handle devise namespace
|
|
134
155
|
def notifications_url_for(target, params = {})
|
|
135
|
-
|
|
156
|
+
options = params.dup
|
|
157
|
+
options.delete(:devise_default_routes) ?
|
|
158
|
+
send("#{routing_scope(options)}notifications_url", options) :
|
|
159
|
+
send("#{routing_scope(options)}#{target.to_resource_name}_notifications_url", target, options)
|
|
136
160
|
end
|
|
137
161
|
|
|
138
162
|
# Returns notification_url for the target of specified notification
|
|
@@ -143,7 +167,10 @@ module ActivityNotification
|
|
|
143
167
|
# @todo Needs any other better implementation
|
|
144
168
|
# @todo Must handle devise namespace
|
|
145
169
|
def notification_url_for(notification, params = {})
|
|
146
|
-
|
|
170
|
+
options = params.dup
|
|
171
|
+
options.delete(:devise_default_routes) ?
|
|
172
|
+
send("#{routing_scope(options)}notification_url", notification, options) :
|
|
173
|
+
send("#{routing_scope(options)}#{notification.target.to_resource_name}_notification_url", notification.target, notification, options)
|
|
147
174
|
end
|
|
148
175
|
|
|
149
176
|
# Returns move_notification_url for the target of specified notification
|
|
@@ -154,7 +181,10 @@ module ActivityNotification
|
|
|
154
181
|
# @todo Needs any other better implementation
|
|
155
182
|
# @todo Must handle devise namespace
|
|
156
183
|
def move_notification_url_for(notification, params = {})
|
|
157
|
-
|
|
184
|
+
options = params.dup
|
|
185
|
+
options.delete(:devise_default_routes) ?
|
|
186
|
+
send("move_#{routing_scope(options)}notification_url", notification, options) :
|
|
187
|
+
send("move_#{routing_scope(options)}#{notification.target.to_resource_name}_notification_url", notification.target, notification, options)
|
|
158
188
|
end
|
|
159
189
|
|
|
160
190
|
# Returns open_notification_url for the target of specified notification
|
|
@@ -165,7 +195,10 @@ module ActivityNotification
|
|
|
165
195
|
# @todo Needs any other better implementation
|
|
166
196
|
# @todo Must handle devise namespace
|
|
167
197
|
def open_notification_url_for(notification, params = {})
|
|
168
|
-
|
|
198
|
+
options = params.dup
|
|
199
|
+
options.delete(:devise_default_routes) ?
|
|
200
|
+
send("open_#{routing_scope(options)}notification_url", notification, options) :
|
|
201
|
+
send("open_#{routing_scope(options)}#{notification.target.to_resource_name}_notification_url", notification.target, notification, options)
|
|
169
202
|
end
|
|
170
203
|
|
|
171
204
|
# Returns open_all_notifications_url for the target of specified notification
|
|
@@ -176,7 +209,10 @@ module ActivityNotification
|
|
|
176
209
|
# @todo Needs any other better implementation
|
|
177
210
|
# @todo Must handle devise namespace
|
|
178
211
|
def open_all_notifications_url_for(target, params = {})
|
|
179
|
-
|
|
212
|
+
options = params.dup
|
|
213
|
+
options.delete(:devise_default_routes) ?
|
|
214
|
+
send("open_all_#{routing_scope(options)}notifications_url", options) :
|
|
215
|
+
send("open_all_#{routing_scope(options)}#{target.to_resource_name}_notifications_url", target, options)
|
|
180
216
|
end
|
|
181
217
|
|
|
182
218
|
# Returns subscriptions_path for the target
|
|
@@ -186,7 +222,10 @@ module ActivityNotification
|
|
|
186
222
|
# @return [String] subscriptions_path for the target
|
|
187
223
|
# @todo Needs any other better implementation
|
|
188
224
|
def subscriptions_path_for(target, params = {})
|
|
189
|
-
|
|
225
|
+
options = params.dup
|
|
226
|
+
options.delete(:devise_default_routes) ?
|
|
227
|
+
send("#{routing_scope(options)}subscriptions_path", options) :
|
|
228
|
+
send("#{routing_scope(options)}#{target.to_resource_name}_subscriptions_path", target, options)
|
|
190
229
|
end
|
|
191
230
|
|
|
192
231
|
# Returns subscription_path for the subscription
|
|
@@ -196,7 +235,10 @@ module ActivityNotification
|
|
|
196
235
|
# @return [String] subscription_path for the subscription
|
|
197
236
|
# @todo Needs any other better implementation
|
|
198
237
|
def subscription_path_for(subscription, params = {})
|
|
199
|
-
|
|
238
|
+
options = params.dup
|
|
239
|
+
options.delete(:devise_default_routes) ?
|
|
240
|
+
send("#{routing_scope(options)}subscription_path", subscription, options) :
|
|
241
|
+
send("#{routing_scope(options)}#{subscription.target.to_resource_name}_subscription_path", subscription.target, subscription, options)
|
|
200
242
|
end
|
|
201
243
|
|
|
202
244
|
# Returns subscribe_subscription_path for the target of specified subscription
|
|
@@ -206,7 +248,10 @@ module ActivityNotification
|
|
|
206
248
|
# @return [String] subscription_path for the subscription
|
|
207
249
|
# @todo Needs any other better implementation
|
|
208
250
|
def subscribe_subscription_path_for(subscription, params = {})
|
|
209
|
-
|
|
251
|
+
options = params.dup
|
|
252
|
+
options.delete(:devise_default_routes) ?
|
|
253
|
+
send("subscribe_#{routing_scope(options)}subscription_path", subscription, options) :
|
|
254
|
+
send("subscribe_#{routing_scope(options)}#{subscription.target.to_resource_name}_subscription_path", subscription.target, subscription, options)
|
|
210
255
|
end
|
|
211
256
|
alias_method :subscribe_path_for, :subscribe_subscription_path_for
|
|
212
257
|
|
|
@@ -217,7 +262,10 @@ module ActivityNotification
|
|
|
217
262
|
# @return [String] subscription_path for the subscription
|
|
218
263
|
# @todo Needs any other better implementation
|
|
219
264
|
def unsubscribe_subscription_path_for(subscription, params = {})
|
|
220
|
-
|
|
265
|
+
options = params.dup
|
|
266
|
+
options.delete(:devise_default_routes) ?
|
|
267
|
+
send("unsubscribe_#{routing_scope(options)}subscription_path", subscription, options) :
|
|
268
|
+
send("unsubscribe_#{routing_scope(options)}#{subscription.target.to_resource_name}_subscription_path", subscription.target, subscription, options)
|
|
221
269
|
end
|
|
222
270
|
alias_method :unsubscribe_path_for, :unsubscribe_subscription_path_for
|
|
223
271
|
|
|
@@ -228,7 +276,10 @@ module ActivityNotification
|
|
|
228
276
|
# @return [String] subscription_path for the subscription
|
|
229
277
|
# @todo Needs any other better implementation
|
|
230
278
|
def subscribe_to_email_subscription_path_for(subscription, params = {})
|
|
231
|
-
|
|
279
|
+
options = params.dup
|
|
280
|
+
options.delete(:devise_default_routes) ?
|
|
281
|
+
send("subscribe_to_email_#{routing_scope(options)}subscription_path", subscription, options) :
|
|
282
|
+
send("subscribe_to_email_#{routing_scope(options)}#{subscription.target.to_resource_name}_subscription_path", subscription.target, subscription, options)
|
|
232
283
|
end
|
|
233
284
|
alias_method :subscribe_to_email_path_for, :subscribe_to_email_subscription_path_for
|
|
234
285
|
|
|
@@ -239,7 +290,10 @@ module ActivityNotification
|
|
|
239
290
|
# @return [String] subscription_path for the subscription
|
|
240
291
|
# @todo Needs any other better implementation
|
|
241
292
|
def unsubscribe_to_email_subscription_path_for(subscription, params = {})
|
|
242
|
-
|
|
293
|
+
options = params.dup
|
|
294
|
+
options.delete(:devise_default_routes) ?
|
|
295
|
+
send("unsubscribe_to_email_#{routing_scope(options)}subscription_path", subscription, options) :
|
|
296
|
+
send("unsubscribe_to_email_#{routing_scope(options)}#{subscription.target.to_resource_name}_subscription_path", subscription.target, subscription, options)
|
|
243
297
|
end
|
|
244
298
|
alias_method :unsubscribe_to_email_path_for, :unsubscribe_to_email_subscription_path_for
|
|
245
299
|
|
|
@@ -250,7 +304,10 @@ module ActivityNotification
|
|
|
250
304
|
# @return [String] subscription_path for the subscription
|
|
251
305
|
# @todo Needs any other better implementation
|
|
252
306
|
def subscribe_to_optional_target_subscription_path_for(subscription, params = {})
|
|
253
|
-
|
|
307
|
+
options = params.dup
|
|
308
|
+
options.delete(:devise_default_routes) ?
|
|
309
|
+
send("subscribe_to_optional_target_#{routing_scope(options)}subscription_path", subscription, options) :
|
|
310
|
+
send("subscribe_to_optional_target_#{routing_scope(options)}#{subscription.target.to_resource_name}_subscription_path", subscription.target, subscription, options)
|
|
254
311
|
end
|
|
255
312
|
alias_method :subscribe_to_optional_target_path_for, :subscribe_to_optional_target_subscription_path_for
|
|
256
313
|
|
|
@@ -261,7 +318,10 @@ module ActivityNotification
|
|
|
261
318
|
# @return [String] subscription_path for the subscription
|
|
262
319
|
# @todo Needs any other better implementation
|
|
263
320
|
def unsubscribe_to_optional_target_subscription_path_for(subscription, params = {})
|
|
264
|
-
|
|
321
|
+
options = params.dup
|
|
322
|
+
options.delete(:devise_default_routes) ?
|
|
323
|
+
send("unsubscribe_to_optional_target_#{routing_scope(options)}subscription_path", subscription, options) :
|
|
324
|
+
send("unsubscribe_to_optional_target_#{routing_scope(options)}#{subscription.target.to_resource_name}_subscription_path", subscription.target, subscription, options)
|
|
265
325
|
end
|
|
266
326
|
alias_method :unsubscribe_to_optional_target_path_for, :unsubscribe_to_optional_target_subscription_path_for
|
|
267
327
|
|
|
@@ -272,7 +332,10 @@ module ActivityNotification
|
|
|
272
332
|
# @return [String] subscriptions_url for the target
|
|
273
333
|
# @todo Needs any other better implementation
|
|
274
334
|
def subscriptions_url_for(target, params = {})
|
|
275
|
-
|
|
335
|
+
options = params.dup
|
|
336
|
+
options.delete(:devise_default_routes) ?
|
|
337
|
+
send("#{routing_scope(options)}subscriptions_url", options) :
|
|
338
|
+
send("#{routing_scope(options)}#{target.to_resource_name}_subscriptions_url", target, options)
|
|
276
339
|
end
|
|
277
340
|
|
|
278
341
|
# Returns subscription_url for the subscription
|
|
@@ -282,7 +345,10 @@ module ActivityNotification
|
|
|
282
345
|
# @return [String] subscription_url for the subscription
|
|
283
346
|
# @todo Needs any other better implementation
|
|
284
347
|
def subscription_url_for(subscription, params = {})
|
|
285
|
-
|
|
348
|
+
options = params.dup
|
|
349
|
+
options.delete(:devise_default_routes) ?
|
|
350
|
+
send("#{routing_scope(options)}subscription_url", subscription, options) :
|
|
351
|
+
send("#{routing_scope(options)}#{subscription.target.to_resource_name}_subscription_url", subscription.target, subscription, options)
|
|
286
352
|
end
|
|
287
353
|
|
|
288
354
|
# Returns subscribe_subscription_url for the target of specified subscription
|
|
@@ -292,7 +358,10 @@ module ActivityNotification
|
|
|
292
358
|
# @return [String] subscription_url for the subscription
|
|
293
359
|
# @todo Needs any other better implementation
|
|
294
360
|
def subscribe_subscription_url_for(subscription, params = {})
|
|
295
|
-
|
|
361
|
+
options = params.dup
|
|
362
|
+
options.delete(:devise_default_routes) ?
|
|
363
|
+
send("subscribe_#{routing_scope(options)}subscription_url", subscription, options) :
|
|
364
|
+
send("subscribe_#{routing_scope(options)}#{subscription.target.to_resource_name}_subscription_url", subscription.target, subscription, options)
|
|
296
365
|
end
|
|
297
366
|
alias_method :subscribe_url_for, :subscribe_subscription_url_for
|
|
298
367
|
|
|
@@ -303,7 +372,10 @@ module ActivityNotification
|
|
|
303
372
|
# @return [String] subscription_url for the subscription
|
|
304
373
|
# @todo Needs any other better implementation
|
|
305
374
|
def unsubscribe_subscription_url_for(subscription, params = {})
|
|
306
|
-
|
|
375
|
+
options = params.dup
|
|
376
|
+
options.delete(:devise_default_routes) ?
|
|
377
|
+
send("unsubscribe_#{routing_scope(options)}subscription_url", subscription, options) :
|
|
378
|
+
send("unsubscribe_#{routing_scope(options)}#{subscription.target.to_resource_name}_subscription_url", subscription.target, subscription, options)
|
|
307
379
|
end
|
|
308
380
|
alias_method :unsubscribe_url_for, :unsubscribe_subscription_url_for
|
|
309
381
|
|
|
@@ -314,7 +386,10 @@ module ActivityNotification
|
|
|
314
386
|
# @return [String] subscription_url for the subscription
|
|
315
387
|
# @todo Needs any other better implementation
|
|
316
388
|
def subscribe_to_email_subscription_url_for(subscription, params = {})
|
|
317
|
-
|
|
389
|
+
options = params.dup
|
|
390
|
+
options.delete(:devise_default_routes) ?
|
|
391
|
+
send("subscribe_to_email_#{routing_scope(options)}subscription_url", subscription, options) :
|
|
392
|
+
send("subscribe_to_email_#{routing_scope(options)}#{subscription.target.to_resource_name}_subscription_url", subscription.target, subscription, options)
|
|
318
393
|
end
|
|
319
394
|
alias_method :subscribe_to_email_url_for, :subscribe_to_email_subscription_url_for
|
|
320
395
|
|
|
@@ -325,7 +400,10 @@ module ActivityNotification
|
|
|
325
400
|
# @return [String] subscription_url for the subscription
|
|
326
401
|
# @todo Needs any other better implementation
|
|
327
402
|
def unsubscribe_to_email_subscription_url_for(subscription, params = {})
|
|
328
|
-
|
|
403
|
+
options = params.dup
|
|
404
|
+
options.delete(:devise_default_routes) ?
|
|
405
|
+
send("unsubscribe_to_email_#{routing_scope(options)}subscription_url", subscription, options) :
|
|
406
|
+
send("unsubscribe_to_email_#{routing_scope(options)}#{subscription.target.to_resource_name}_subscription_url", subscription.target, subscription, options)
|
|
329
407
|
end
|
|
330
408
|
alias_method :unsubscribe_to_email_url_for, :unsubscribe_to_email_subscription_url_for
|
|
331
409
|
|
|
@@ -336,7 +414,10 @@ module ActivityNotification
|
|
|
336
414
|
# @return [String] subscription_url for the subscription
|
|
337
415
|
# @todo Needs any other better implementation
|
|
338
416
|
def subscribe_to_optional_target_subscription_url_for(subscription, params = {})
|
|
339
|
-
|
|
417
|
+
options = params.dup
|
|
418
|
+
options.delete(:devise_default_routes) ?
|
|
419
|
+
send("subscribe_to_optional_target_#{routing_scope(options)}subscription_url", subscription, options) :
|
|
420
|
+
send("subscribe_to_optional_target_#{routing_scope(options)}#{subscription.target.to_resource_name}_subscription_url", subscription.target, subscription, options)
|
|
340
421
|
end
|
|
341
422
|
alias_method :subscribe_to_optional_target_url_for, :subscribe_to_optional_target_subscription_url_for
|
|
342
423
|
|
|
@@ -347,7 +428,10 @@ module ActivityNotification
|
|
|
347
428
|
# @return [String] subscription_url for the subscription
|
|
348
429
|
# @todo Needs any other better implementation
|
|
349
430
|
def unsubscribe_to_optional_target_subscription_url_for(subscription, params = {})
|
|
350
|
-
|
|
431
|
+
options = params.dup
|
|
432
|
+
options.delete(:devise_default_routes) ?
|
|
433
|
+
send("unsubscribe_to_optional_target_#{routing_scope(options)}subscription_url", subscription, options) :
|
|
434
|
+
send("unsubscribe_to_optional_target_#{routing_scope(options)}#{subscription.target.to_resource_name}_subscription_url", subscription.target, subscription, options)
|
|
351
435
|
end
|
|
352
436
|
alias_method :unsubscribe_to_optional_target_url_for, :unsubscribe_to_optional_target_subscription_url_for
|
|
353
437
|
|
|
@@ -441,6 +525,12 @@ module ActivityNotification
|
|
|
441
525
|
[root, path].map(&:to_s).join('/')
|
|
442
526
|
end
|
|
443
527
|
|
|
528
|
+
# Prepare routing scope from options
|
|
529
|
+
# @api private
|
|
530
|
+
def routing_scope(options = {})
|
|
531
|
+
options[:routing_scope] ? options.delete(:routing_scope).to_s + '_' : ''
|
|
532
|
+
end
|
|
533
|
+
|
|
444
534
|
end
|
|
445
535
|
|
|
446
536
|
ActionView::Base.class_eval { include ViewHelpers }
|
|
@@ -58,21 +58,28 @@ module ActivityNotification
|
|
|
58
58
|
@notification.notifiable.overriding_notification_email_key(@target, key).present?
|
|
59
59
|
key = @notification.notifiable.overriding_notification_email_key(@target, key)
|
|
60
60
|
end
|
|
61
|
-
if @notification.notifiable.respond_to?(:overriding_notification_email_subject) &&
|
|
62
|
-
@notification.notifiable.overriding_notification_email_subject(@target, key).present?
|
|
63
|
-
subject = @notification.notifiable.overriding_notification_email_subject(@target, key)
|
|
64
|
-
else
|
|
65
|
-
subject = subject_for(key)
|
|
66
|
-
end
|
|
67
61
|
headers = {
|
|
68
|
-
subject: subject,
|
|
69
62
|
to: mailer_to(@target),
|
|
70
|
-
from: mailer_from(key),
|
|
71
|
-
reply_to: mailer_reply_to(key),
|
|
72
63
|
template_path: template_paths,
|
|
73
64
|
template_name: template_name(key)
|
|
74
65
|
}.merge(options)
|
|
75
|
-
|
|
66
|
+
{
|
|
67
|
+
subject: :subject_for,
|
|
68
|
+
from: :mailer_from,
|
|
69
|
+
reply_to: :mailer_reply_to,
|
|
70
|
+
message_id: nil
|
|
71
|
+
}.each do |header_name, default_method|
|
|
72
|
+
overridding_method_name = "overriding_notification_email_#{header_name.to_s}"
|
|
73
|
+
header_value = if @notification.notifiable.respond_to?(overridding_method_name) &&
|
|
74
|
+
@notification.notifiable.send(overridding_method_name, @target, key).present?
|
|
75
|
+
@notification.notifiable.send(overridding_method_name, @target, key)
|
|
76
|
+
elsif default_method
|
|
77
|
+
send(default_method, key)
|
|
78
|
+
else
|
|
79
|
+
nil
|
|
80
|
+
end
|
|
81
|
+
headers[header_name] = header_value if header_value
|
|
82
|
+
end
|
|
76
83
|
@email = headers[:to]
|
|
77
84
|
headers
|
|
78
85
|
end
|
|
@@ -120,8 +127,8 @@ module ActivityNotification
|
|
|
120
127
|
#
|
|
121
128
|
# @return [Array<String>] Template paths to find email view
|
|
122
129
|
def template_paths
|
|
123
|
-
paths = [
|
|
124
|
-
paths.unshift("
|
|
130
|
+
paths = ["#{ActivityNotification.config.mailer_templates_dir}/default"]
|
|
131
|
+
paths.unshift("#{ActivityNotification.config.mailer_templates_dir}/#{@target.to_resources_name}") if @target.present?
|
|
125
132
|
paths
|
|
126
133
|
end
|
|
127
134
|
|