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.
Files changed (271) hide show
  1. checksums.yaml +5 -5
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +22 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
  4. data/.github/pull_request_template.md +13 -0
  5. data/.github/workflows/build.yml +116 -0
  6. data/.gitignore +15 -3
  7. data/CHANGELOG.md +200 -1
  8. data/Gemfile +17 -2
  9. data/Procfile +2 -0
  10. data/README.md +168 -1033
  11. data/Rakefile +19 -10
  12. data/activity_notification.gemspec +14 -9
  13. data/app/channels/activity_notification/notification_api_channel.rb +12 -0
  14. data/app/channels/activity_notification/notification_api_with_devise_channel.rb +46 -0
  15. data/app/channels/activity_notification/notification_channel.rb +37 -0
  16. data/app/channels/activity_notification/notification_with_devise_channel.rb +51 -0
  17. data/app/controllers/activity_notification/apidocs_controller.rb +75 -0
  18. data/app/controllers/activity_notification/notifications_api_controller.rb +143 -0
  19. data/app/controllers/activity_notification/notifications_api_with_devise_controller.rb +7 -0
  20. data/app/controllers/activity_notification/notifications_controller.rb +60 -54
  21. data/app/controllers/activity_notification/subscriptions_api_controller.rb +197 -0
  22. data/app/controllers/activity_notification/subscriptions_api_with_devise_controller.rb +7 -0
  23. data/app/controllers/activity_notification/subscriptions_controller.rb +83 -73
  24. data/app/jobs/activity_notification/notify_all_job.rb +25 -0
  25. data/app/jobs/activity_notification/notify_job.rb +26 -0
  26. data/app/jobs/activity_notification/notify_to_job.rb +25 -0
  27. data/app/views/activity_notification/notifications/default/_default.html.erb +23 -23
  28. data/app/views/activity_notification/notifications/default/_default_without_grouping.html.erb +19 -19
  29. data/app/views/activity_notification/notifications/default/_index.html.erb +3 -3
  30. data/app/views/activity_notification/notifications/default/index.html.erb +60 -7
  31. data/app/views/activity_notification/notifications/default/open.js.erb +2 -2
  32. data/app/views/activity_notification/notifications/default/open_all.js.erb +2 -2
  33. data/app/views/activity_notification/notifications/default/show.html.erb +2 -2
  34. data/app/views/activity_notification/optional_targets/default/action_cable_channel/_default.html.erb +176 -0
  35. data/app/views/activity_notification/optional_targets/default/base/_default.text.erb +1 -1
  36. data/app/views/activity_notification/optional_targets/default/slack/_default.text.erb +1 -1
  37. data/app/views/activity_notification/subscriptions/default/_form.html.erb +2 -2
  38. data/app/views/activity_notification/subscriptions/default/_notification_keys.html.erb +5 -33
  39. data/app/views/activity_notification/subscriptions/default/_subscription.html.erb +8 -8
  40. data/app/views/activity_notification/subscriptions/default/index.html.erb +13 -9
  41. data/app/views/activity_notification/subscriptions/default/show.html.erb +3 -3
  42. data/app/views/activity_notification/subscriptions/default/subscribe.js.erb +1 -1
  43. data/app/views/activity_notification/subscriptions/default/subscribe_to_email.js.erb +1 -1
  44. data/app/views/activity_notification/subscriptions/default/subscribe_to_optional_target.js.erb +1 -1
  45. data/app/views/activity_notification/subscriptions/default/unsubscribe.js.erb +1 -1
  46. data/app/views/activity_notification/subscriptions/default/unsubscribe_to_email.js.erb +1 -1
  47. data/app/views/activity_notification/subscriptions/default/unsubscribe_to_optional_target.js.erb +1 -1
  48. data/bin/_dynamodblocal +4 -0
  49. data/bin/bundle_update.sh +7 -0
  50. data/bin/deploy_on_heroku.sh +16 -0
  51. data/bin/install_dynamodblocal.sh +5 -0
  52. data/bin/start_dynamodblocal.sh +47 -0
  53. data/bin/stop_dynamodblocal.sh +34 -0
  54. data/docs/CODE_OF_CONDUCT.md +76 -0
  55. data/docs/CONTRIBUTING.md +36 -0
  56. data/docs/Functions.md +1146 -0
  57. data/docs/Setup.md +817 -0
  58. data/docs/Testing.md +148 -0
  59. data/gemfiles/Gemfile.rails-5.0 +8 -1
  60. data/gemfiles/Gemfile.rails-5.1 +7 -1
  61. data/gemfiles/Gemfile.rails-5.2 +24 -0
  62. data/gemfiles/Gemfile.rails-6.0 +23 -0
  63. data/gemfiles/Gemfile.rails-6.1 +22 -0
  64. data/gemfiles/Gemfile.rails-7.0 +25 -0
  65. data/lib/activity_notification/apis/notification_api.rb +356 -159
  66. data/lib/activity_notification/apis/subscription_api.rb +98 -59
  67. data/lib/activity_notification/apis/swagger.rb +6 -0
  68. data/lib/activity_notification/common.rb +18 -7
  69. data/lib/activity_notification/config.rb +176 -30
  70. data/lib/activity_notification/controllers/common_api_controller.rb +30 -0
  71. data/lib/activity_notification/controllers/common_controller.rb +47 -27
  72. data/lib/activity_notification/controllers/concerns/swagger/error_responses.rb +55 -0
  73. data/lib/activity_notification/controllers/concerns/swagger/notifications_api.rb +273 -0
  74. data/lib/activity_notification/controllers/concerns/swagger/notifications_parameters.rb +92 -0
  75. data/lib/activity_notification/controllers/concerns/swagger/subscriptions_api.rb +405 -0
  76. data/lib/activity_notification/controllers/concerns/swagger/subscriptions_parameters.rb +50 -0
  77. data/lib/activity_notification/controllers/devise_authentication_controller.rb +22 -5
  78. data/lib/activity_notification/gem_version.rb +14 -0
  79. data/lib/activity_notification/helpers/errors.rb +6 -0
  80. data/lib/activity_notification/helpers/view_helpers.rb +118 -28
  81. data/lib/activity_notification/mailers/helpers.rb +19 -12
  82. data/lib/activity_notification/models/concerns/notifiable.rb +142 -55
  83. data/lib/activity_notification/models/concerns/subscriber.rb +28 -13
  84. data/lib/activity_notification/models/concerns/swagger/error_schema.rb +36 -0
  85. data/lib/activity_notification/models/concerns/swagger/notification_schema.rb +209 -0
  86. data/lib/activity_notification/models/concerns/swagger/subscription_schema.rb +162 -0
  87. data/lib/activity_notification/models/concerns/target.rb +131 -32
  88. data/lib/activity_notification/models/notification.rb +1 -0
  89. data/lib/activity_notification/models/subscription.rb +1 -0
  90. data/lib/activity_notification/models.rb +23 -1
  91. data/lib/activity_notification/optional_targets/action_cable_api_channel.rb +69 -0
  92. data/lib/activity_notification/optional_targets/action_cable_channel.rb +68 -0
  93. data/lib/activity_notification/optional_targets/base.rb +9 -15
  94. data/lib/activity_notification/orm/active_record/notification.rb +23 -34
  95. data/lib/activity_notification/orm/active_record/subscription.rb +1 -1
  96. data/lib/activity_notification/orm/active_record.rb +1 -1
  97. data/lib/activity_notification/orm/dynamoid/extension.rb +262 -0
  98. data/lib/activity_notification/orm/dynamoid/notification.rb +224 -0
  99. data/lib/activity_notification/orm/dynamoid/subscription.rb +82 -0
  100. data/lib/activity_notification/orm/dynamoid.rb +530 -0
  101. data/lib/activity_notification/orm/mongoid/notification.rb +29 -28
  102. data/lib/activity_notification/orm/mongoid/subscription.rb +3 -3
  103. data/lib/activity_notification/orm/mongoid.rb +33 -1
  104. data/lib/activity_notification/rails/routes.rb +273 -60
  105. data/lib/activity_notification/renderable.rb +22 -7
  106. data/lib/activity_notification/roles/acts_as_notifiable.rb +64 -1
  107. data/lib/activity_notification/roles/acts_as_target.rb +99 -9
  108. data/lib/activity_notification/version.rb +1 -1
  109. data/lib/activity_notification.rb +14 -0
  110. data/lib/generators/activity_notification/controllers_generator.rb +2 -1
  111. data/lib/generators/templates/activity_notification.rb +61 -7
  112. data/lib/generators/templates/controllers/README +2 -2
  113. data/lib/generators/templates/controllers/notifications_api_controller.rb +31 -0
  114. data/lib/generators/templates/controllers/notifications_api_with_devise_controller.rb +31 -0
  115. data/lib/generators/templates/controllers/notifications_controller.rb +1 -37
  116. data/lib/generators/templates/controllers/notifications_with_devise_controller.rb +1 -45
  117. data/lib/generators/templates/controllers/subscriptions_api_controller.rb +61 -0
  118. data/lib/generators/templates/controllers/subscriptions_api_with_devise_controller.rb +61 -0
  119. data/lib/generators/templates/controllers/subscriptions_controller.rb +14 -37
  120. data/lib/generators/templates/controllers/subscriptions_with_devise_controller.rb +14 -45
  121. data/lib/generators/templates/migrations/migration.rb +5 -5
  122. data/lib/generators/templates/models/README +8 -4
  123. data/lib/generators/templates/models/notification.rb +1 -1
  124. data/lib/generators/templates/models/subscription.rb +1 -1
  125. data/lib/tasks/activity_notification_tasks.rake +14 -4
  126. data/package.json +8 -0
  127. data/spec/channels/notification_api_channel_shared_examples.rb +59 -0
  128. data/spec/channels/notification_api_channel_spec.rb +49 -0
  129. data/spec/channels/notification_api_with_devise_channel_spec.rb +76 -0
  130. data/spec/channels/notification_channel_shared_examples.rb +59 -0
  131. data/spec/channels/notification_channel_spec.rb +48 -0
  132. data/spec/channels/notification_with_devise_channel_spec.rb +97 -0
  133. data/spec/concerns/apis/notification_api_spec.rb +177 -12
  134. data/spec/concerns/apis/subscription_api_spec.rb +146 -4
  135. data/spec/concerns/common_spec.rb +25 -3
  136. data/spec/concerns/models/notifiable_spec.rb +161 -11
  137. data/spec/concerns/models/subscriber_spec.rb +253 -79
  138. data/spec/concerns/models/target_spec.rb +180 -47
  139. data/spec/concerns/renderable_spec.rb +35 -16
  140. data/spec/config_spec.rb +52 -1
  141. data/spec/controllers/controller_spec_utility.rb +100 -0
  142. data/spec/controllers/notifications_api_controller_shared_examples.rb +506 -0
  143. data/spec/controllers/notifications_api_controller_spec.rb +19 -0
  144. data/spec/controllers/notifications_api_with_devise_controller_spec.rb +60 -0
  145. data/spec/controllers/notifications_controller_shared_examples.rb +55 -76
  146. data/spec/controllers/notifications_controller_spec.rb +1 -2
  147. data/spec/controllers/notifications_with_devise_controller_spec.rb +14 -8
  148. data/spec/controllers/subscriptions_api_controller_shared_examples.rb +750 -0
  149. data/spec/controllers/subscriptions_api_controller_spec.rb +19 -0
  150. data/spec/controllers/subscriptions_api_with_devise_controller_spec.rb +60 -0
  151. data/spec/controllers/subscriptions_controller_shared_examples.rb +99 -121
  152. data/spec/controllers/subscriptions_controller_spec.rb +1 -2
  153. data/spec/controllers/subscriptions_with_devise_controller_spec.rb +14 -8
  154. data/spec/factories/notifications.rb +1 -1
  155. data/spec/factories/subscriptions.rb +3 -3
  156. data/spec/factories/users.rb +3 -3
  157. data/spec/generators/migration/migration_generator_spec.rb +29 -4
  158. data/spec/helpers/view_helpers_spec.rb +31 -21
  159. data/spec/jobs/notify_all_job_spec.rb +23 -0
  160. data/spec/jobs/notify_job_spec.rb +23 -0
  161. data/spec/jobs/notify_to_job_spec.rb +23 -0
  162. data/spec/mailers/mailer_spec.rb +42 -1
  163. data/spec/models/dummy/dummy_group_spec.rb +4 -0
  164. data/spec/models/dummy/dummy_notifiable_spec.rb +4 -0
  165. data/spec/models/dummy/dummy_notifier_spec.rb +4 -0
  166. data/spec/models/dummy/dummy_subscriber_spec.rb +3 -0
  167. data/spec/models/dummy/dummy_target_spec.rb +4 -0
  168. data/spec/models/notification_spec.rb +181 -45
  169. data/spec/models/subscription_spec.rb +77 -27
  170. data/spec/optional_targets/action_cable_api_channel_spec.rb +34 -0
  171. data/spec/optional_targets/action_cable_channel_spec.rb +41 -0
  172. data/spec/optional_targets/amazon_sns_spec.rb +0 -2
  173. data/spec/optional_targets/slack_spec.rb +0 -2
  174. data/spec/orm/dynamoid_spec.rb +115 -0
  175. data/spec/rails_app/Rakefile +9 -0
  176. data/spec/rails_app/app/assets/config/manifest.js +3 -0
  177. data/spec/rails_app/app/assets/javascripts/application.js +2 -1
  178. data/spec/rails_app/app/assets/javascripts/cable.js +12 -0
  179. data/spec/rails_app/app/controllers/admins_controller.rb +21 -0
  180. data/spec/rails_app/app/controllers/application_controller.rb +1 -1
  181. data/spec/rails_app/app/controllers/articles_controller.rb +6 -1
  182. data/spec/rails_app/app/controllers/comments_controller.rb +3 -1
  183. data/spec/rails_app/app/controllers/spa_controller.rb +7 -0
  184. data/spec/rails_app/app/controllers/users/notifications_controller.rb +0 -65
  185. data/spec/rails_app/app/controllers/users/notifications_with_devise_controller.rb +0 -73
  186. data/spec/rails_app/app/controllers/users/subscriptions_controller.rb +0 -77
  187. data/spec/rails_app/app/controllers/users/subscriptions_with_devise_controller.rb +0 -85
  188. data/spec/rails_app/app/controllers/users_controller.rb +26 -0
  189. data/spec/rails_app/app/javascript/App.vue +40 -0
  190. data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +82 -0
  191. data/spec/rails_app/app/javascript/components/Top.vue +98 -0
  192. data/spec/rails_app/app/javascript/components/notifications/Index.vue +200 -0
  193. data/spec/rails_app/app/javascript/components/notifications/Notification.vue +133 -0
  194. data/spec/rails_app/app/javascript/components/notifications/NotificationContent.vue +122 -0
  195. data/spec/rails_app/app/javascript/components/subscriptions/Index.vue +279 -0
  196. data/spec/rails_app/app/javascript/components/subscriptions/NewSubscription.vue +112 -0
  197. data/spec/rails_app/app/javascript/components/subscriptions/NotificationKey.vue +141 -0
  198. data/spec/rails_app/app/javascript/components/subscriptions/Subscription.vue +226 -0
  199. data/spec/rails_app/app/javascript/config/development.js +5 -0
  200. data/spec/rails_app/app/javascript/config/environment.js +7 -0
  201. data/spec/rails_app/app/javascript/config/production.js +5 -0
  202. data/spec/rails_app/app/javascript/config/test.js +5 -0
  203. data/spec/rails_app/app/javascript/packs/application.js +18 -0
  204. data/spec/rails_app/app/javascript/packs/spa.js +14 -0
  205. data/spec/rails_app/app/javascript/router/index.js +73 -0
  206. data/spec/rails_app/app/javascript/store/index.js +37 -0
  207. data/spec/rails_app/app/models/admin.rb +15 -10
  208. data/spec/rails_app/app/models/article.rb +25 -20
  209. data/spec/rails_app/app/models/comment.rb +27 -62
  210. data/spec/rails_app/app/models/dummy/dummy_base.rb +1 -0
  211. data/spec/rails_app/app/models/dummy/dummy_group.rb +9 -0
  212. data/spec/rails_app/app/models/dummy/dummy_notifiable.rb +1 -0
  213. data/spec/rails_app/app/models/dummy/dummy_notifiable_target.rb +27 -0
  214. data/spec/rails_app/app/models/dummy/dummy_notifier.rb +1 -0
  215. data/spec/rails_app/app/models/dummy/dummy_subscriber.rb +1 -0
  216. data/spec/rails_app/app/models/dummy/dummy_target.rb +1 -0
  217. data/spec/rails_app/app/models/user.rb +44 -18
  218. data/spec/rails_app/app/views/activity_notification/notifications/default/article/_update.html.erb +146 -0
  219. data/spec/rails_app/app/views/activity_notification/notifications/users/overridden/custom/_test.html.erb +1 -0
  220. data/spec/rails_app/app/views/activity_notification/optional_targets/admins/amazon_sns/comment/_default.text.erb +1 -1
  221. data/spec/rails_app/app/views/articles/index.html.erb +68 -20
  222. data/spec/rails_app/app/views/articles/show.html.erb +1 -1
  223. data/spec/rails_app/app/views/layouts/_header.html.erb +9 -3
  224. data/spec/rails_app/app/views/spa/index.html.erb +2 -0
  225. data/spec/rails_app/babel.config.js +72 -0
  226. data/spec/rails_app/bin/webpack +18 -0
  227. data/spec/rails_app/bin/webpack-dev-server +18 -0
  228. data/spec/rails_app/config/application.rb +26 -6
  229. data/spec/rails_app/config/cable.yml +8 -0
  230. data/spec/rails_app/config/database.yml +1 -1
  231. data/spec/rails_app/config/dynamoid.rb +13 -0
  232. data/spec/rails_app/config/environment.rb +5 -1
  233. data/spec/rails_app/config/environments/development.rb +5 -0
  234. data/spec/rails_app/config/environments/production.rb +7 -1
  235. data/spec/rails_app/config/environments/test.rb +7 -11
  236. data/spec/rails_app/config/initializers/activity_notification.rb +63 -9
  237. data/spec/rails_app/config/initializers/copy_it.aws.rb.template +6 -0
  238. data/spec/rails_app/config/initializers/devise_token_auth.rb +55 -0
  239. data/spec/rails_app/config/initializers/mysql.rb +9 -0
  240. data/spec/rails_app/config/locales/activity_notification.en.yml +10 -4
  241. data/spec/rails_app/config/routes.rb +42 -1
  242. data/spec/rails_app/config/webpack/development.js +5 -0
  243. data/spec/rails_app/config/webpack/environment.js +7 -0
  244. data/spec/rails_app/config/webpack/loaders/vue.js +6 -0
  245. data/spec/rails_app/config/webpack/production.js +5 -0
  246. data/spec/rails_app/config/webpack/test.js +5 -0
  247. data/spec/rails_app/config/webpacker.yml +97 -0
  248. data/spec/rails_app/db/migrate/{20160715050433_create_test_tables.rb → 20160716000000_create_test_tables.rb} +1 -1
  249. data/spec/rails_app/db/migrate/{20160715050420_create_activity_notification_tables.rb → 20181209000000_create_activity_notification_tables.rb} +3 -3
  250. data/spec/rails_app/db/migrate/20191201000000_add_tokens_to_users.rb +10 -0
  251. data/spec/rails_app/db/schema.rb +46 -43
  252. data/spec/rails_app/db/seeds.rb +28 -4
  253. data/spec/rails_app/lib/custom_optional_targets/raise_error.rb +14 -0
  254. data/spec/rails_app/lib/mailer_previews/mailer_preview.rb +14 -4
  255. data/spec/rails_app/package.json +23 -0
  256. data/spec/rails_app/postcss.config.js +12 -0
  257. data/spec/roles/acts_as_group_spec.rb +0 -2
  258. data/spec/roles/acts_as_notifiable_spec.rb +80 -20
  259. data/spec/roles/acts_as_notifier_spec.rb +0 -2
  260. data/spec/roles/acts_as_target_spec.rb +1 -5
  261. data/spec/spec_helper.rb +13 -11
  262. data/spec/version_spec.rb +31 -0
  263. metadata +306 -53
  264. data/.travis.yml +0 -85
  265. data/Gemfile.lock +0 -234
  266. data/gemfiles/Gemfile.rails-4.2 +0 -17
  267. data/gemfiles/Gemfile.rails-4.2.lock +0 -225
  268. data/gemfiles/Gemfile.rails-5.0.lock +0 -234
  269. data/gemfiles/Gemfile.rails-5.1.lock +0 -234
  270. data/spec/rails_app/app/views/activity_notification/notifications/users/overriden/custom/_test.html.erb +0 -1
  271. /data/spec/rails_app/app/{models → assets/images}/.keep +0 -0
@@ -1,6 +1,10 @@
1
1
  # Load the Rails application.
2
2
  require File.expand_path('../application', __FILE__)
3
3
 
4
+ # Demo application uses Devise and Devise Token Auth
5
+ require 'devise'
6
+ require 'devise_token_auth'
7
+
4
8
  # Initialize the Rails application.
5
9
  Rails.application.initialize!
6
10
 
@@ -15,7 +19,7 @@ def silent_stdout(&block)
15
19
  end
16
20
 
17
21
  # Load database schema
18
- if Rails.env.test? && ENV['AN_TEST_DB'] != 'mongodb'
22
+ if Rails.env.test? && ['mongodb', 'dynamodb'].exclude?(ENV['AN_TEST_DB'])
19
23
  silent_stdout do
20
24
  load "#{Rails.root}/db/schema.rb"
21
25
  end
@@ -47,6 +47,11 @@ Rails.application.configure do
47
47
  # For notification email preview
48
48
  config.action_mailer.preview_path = "#{Rails.root}/lib/mailer_previews"
49
49
 
50
+ # Specifies delivery job for mail
51
+ if Rails::VERSION::MAJOR >= 6
52
+ config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
53
+ end
54
+
50
55
  # Configration for bullet
51
56
  config.after_initialize do
52
57
  Bullet.enable = true
@@ -25,7 +25,7 @@ Rails.application.configure do
25
25
  config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
26
26
 
27
27
  # Compress JavaScripts and CSS.
28
- config.assets.js_compressor = :uglifier
28
+ # config.assets.js_compressor = :uglifier
29
29
  # config.assets.css_compressor = :sass
30
30
 
31
31
  # Do not fallback to assets pipeline if a precompiled asset is missed.
@@ -64,6 +64,9 @@ Rails.application.configure do
64
64
  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
65
65
  # config.action_mailer.raise_delivery_errors = false
66
66
 
67
+ # Specifies delivery job for mail
68
+ config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
69
+
67
70
  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
68
71
  # the I18n.default_locale when a translation cannot be found).
69
72
  config.i18n.fallbacks = true
@@ -76,4 +79,7 @@ Rails.application.configure do
76
79
 
77
80
  # Do not dump schema after migrations.
78
81
  config.active_record.dump_schema_after_migration = false
82
+
83
+ # Allow Action Cable connection from any host
84
+ config.action_cable.disable_request_forgery_protection = true
79
85
  end
@@ -13,17 +13,8 @@ Rails.application.configure do
13
13
  config.eager_load = false
14
14
 
15
15
  # Configure static file server for tests with Cache-Control for performance.
16
- if Rails::VERSION::MAJOR >= 5
17
- config.public_file_server.enabled = true
18
- else
19
- config.serve_static_files = true
20
- end
21
-
22
- if Rails::VERSION::MAJOR >= 5
23
- config.public_file_server.headers = {'Cache-Control' => 'public, max-age=3600'}
24
- else
25
- config.static_cache_control = "public, max-age=3600"
26
- end
16
+ config.public_file_server.enabled = true
17
+ config.public_file_server.headers = {'Cache-Control' => 'public, max-age=3600'}
27
18
 
28
19
  # Show full error reports and disable caching.
29
20
  config.consider_all_requests_local = true
@@ -54,4 +45,9 @@ Rails.application.configure do
54
45
 
55
46
  # Set default_url_options for devise and notification email.
56
47
  config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
48
+
49
+ # Specifies delivery job for mail
50
+ if Rails::VERSION::MAJOR >= 6
51
+ config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
52
+ end
57
53
  end
@@ -1,19 +1,19 @@
1
1
  ActivityNotification.configure do |config|
2
2
 
3
- # Configure ORM name for ActivityNotification.
4
- # Set :active_record or :mongoid.
5
- ENV['AN_ORM'] = 'active_record' unless ENV['AN_ORM'] == 'mongoid'
6
- config.orm = ENV['AN_ORM']
7
-
8
3
  # Configure if all activity notifications are enabled
9
4
  # Set false when you want to turn off activity notifications
10
5
  config.enabled = true
11
6
 
12
- # Configure table name to store notification data
13
- config.notification_table_name = "notifications"
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
+ # Configure table name to store notification data.
13
+ config.notification_table_name = ENV['AN_NOTIFICATION_TABLE_NAME'] || "notifications"
14
14
 
15
- # Configure table name to store subscription data
16
- config.subscription_table_name = "subscriptions"
15
+ # Configure table name to store subscription data.
16
+ config.subscription_table_name = ENV['AN_SUBSCRIPTION_TABLE_NAME'] || "subscriptions"
17
17
 
18
18
  # Configure if email notification is enabled as default.
19
19
  # Note that you can configure them for each model by acts_as roles.
@@ -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 = (config.orm != :active_record)
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 ctivity_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
@@ -0,0 +1,6 @@
1
+ # Copy this template file as aws.rb and set your credentials
2
+ unless Rails.env.test?
3
+ Aws.config.update({
4
+ credentials: Aws::Credentials.new('your_access_key_id', 'your_secret_access_key')
5
+ })
6
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ DeviseTokenAuth.setup do |config|
4
+ # By default the authorization headers will change after each request. The
5
+ # client is responsible for keeping track of the changing tokens. Change
6
+ # this to false to prevent the Authorization header from changing after
7
+ # each request.
8
+ config.change_headers_on_each_request = false
9
+
10
+ # By default, users will need to re-authenticate after 2 weeks. This setting
11
+ # determines how long tokens will remain valid after they are issued.
12
+ config.token_lifespan = 1.hour
13
+
14
+ # Limiting the token_cost to just 4 in testing will increase the performance of
15
+ # your test suite dramatically. The possible cost value is within range from 4
16
+ # to 31. It is recommended to not use a value more than 10 in other environments.
17
+ config.token_cost = Rails.env.test? ? 4 : 10
18
+
19
+ # Sets the max number of concurrent devices per user, which is 10 by default.
20
+ # After this limit is reached, the oldest tokens will be removed.
21
+ # config.max_number_of_devices = 10
22
+
23
+ # Sometimes it's necessary to make several requests to the API at the same
24
+ # time. In this case, each request in the batch will need to share the same
25
+ # auth token. This setting determines how far apart the requests can be while
26
+ # still using the same auth token.
27
+ # config.batch_request_buffer_throttle = 5.seconds
28
+
29
+ # This route will be the prefix for all oauth2 redirect callbacks. For
30
+ # example, using the default '/omniauth', the github oauth2 provider will
31
+ # redirect successful authentications to '/omniauth/github/callback'
32
+ # config.omniauth_prefix = "/omniauth"
33
+
34
+ # By default sending current password is not needed for the password update.
35
+ # Uncomment to enforce current_password param to be checked before all
36
+ # attribute updates. Set it to :password if you want it to be checked only if
37
+ # password is updated.
38
+ # config.check_current_password_before_update = :attributes
39
+
40
+ # By default we will use callbacks for single omniauth.
41
+ # It depends on fields like email, provider and uid.
42
+ # config.default_callbacks = true
43
+
44
+ # Makes it possible to change the headers names
45
+ # config.headers_names = {:'access-token' => 'access-token',
46
+ # :'client' => 'client',
47
+ # :'expiry' => 'expiry',
48
+ # :'uid' => 'uid',
49
+ # :'token-type' => 'token-type' }
50
+
51
+ # By default, only Bearer Token authentication is implemented out of the box.
52
+ # If, however, you wish to integrate with legacy Devise authentication, you can
53
+ # do so by enabling this flag. NOTE: This feature is highly experimental!
54
+ # config.enable_standard_devise_support = false
55
+ end
@@ -0,0 +1,9 @@
1
+ # Creates DATETIME(3) column types by default which support microseconds.
2
+ # Without it, only regular (second precise) DATETIME columns are created.
3
+ if defined?(ActiveRecord)
4
+ module ActiveRecord::ConnectionAdapters
5
+ if defined?(AbstractMysqlAdapter)
6
+ AbstractMysqlAdapter::NATIVE_DATABASE_TYPES[:datetime][:limit] = 3
7
+ end
8
+ end
9
+ end
@@ -6,14 +6,20 @@ en:
6
6
  article:
7
7
  create:
8
8
  text: 'Article has been created'
9
+ update:
10
+ text: 'Article "%{article_title}" has been updated'
9
11
  destroy:
10
- text: 'Some user removed an article!'
12
+ text: 'The author removed an article "%{article_title}"'
11
13
  comment:
14
+ create:
15
+ text: '%{notifier_name} posted a comment on the article "%{article_title}"'
12
16
  post:
13
- text: "<p>%{notifier_name} posted comments to your article %{article_title}</p>"
17
+ text:
18
+ one: "<p>%{notifier_name} posted a comment on your article %{article_title}</p>"
19
+ other: "<p>%{notifier_name} posted %{count} comments on your article %{article_title}</p>"
14
20
  reply:
15
- text: "<p>%{notifier_name} and %{group_member_count} people replied for your comments</p>"
16
- mail_subject: 'New comment to your article'
21
+ text: "<p>%{notifier_name} and %{group_member_count} other people replied %{group_notification_count} times to your comment</p>"
22
+ mail_subject: 'New comment on your article'
17
23
  admin:
18
24
  article:
19
25
  post:
@@ -1,9 +1,50 @@
1
1
  Rails.application.routes.draw do
2
+ # Routes for example Rails application
2
3
  root to: 'articles#index'
3
4
  devise_for :users
4
- resources :articles
5
+ resources :articles, except: [:destroy]
5
6
  resources :comments, only: [:create, :destroy]
6
7
 
8
+ # activity_notification routes for users
7
9
  notify_to :users, with_subscription: true
10
+ notify_to :users, with_devise: :users, devise_default_routes: true, with_subscription: true
11
+
12
+ # activity_notification routes for admins
8
13
  notify_to :admins, with_devise: :users, with_subscription: true
14
+ scope :admins, as: :admins do
15
+ notify_to :admins, with_devise: :users, devise_default_routes: true, with_subscription: true, routing_scope: :admins
16
+ end
17
+
18
+ # Routes for single page application working with activity_notification REST API backend
19
+ resources :spa, only: [:index]
20
+ namespace :api do
21
+ scope :"v#{ActivityNotification::GEM_VERSION::MAJOR}" do
22
+ mount_devise_token_auth_for 'User', at: 'auth'
23
+ end
24
+ end
25
+
26
+ # Routes of activity_notification REST API backend for users
27
+ scope :api do
28
+ scope :"v#{ActivityNotification::GEM_VERSION::MAJOR}" do
29
+ notify_to :users, api_mode: true, with_subscription: true
30
+ notify_to :users, api_mode: true, with_devise: :users, devise_default_routes: true, with_subscription: true
31
+ resources :apidocs, only: [:index], controller: 'activity_notification/apidocs'
32
+ resources :users, only: [:index, :show] do
33
+ collection do
34
+ get :find
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ # Routes of activity_notification REST API backend for admins
41
+ scope :api do
42
+ scope :"v#{ActivityNotification::GEM_VERSION::MAJOR}" do
43
+ notify_to :admins, api_mode: true, with_devise: :users, with_subscription: true
44
+ scope :admins, as: :admins do
45
+ notify_to :admins, api_mode: true, with_devise: :users, devise_default_routes: true, with_subscription: true
46
+ end
47
+ resources :admins, only: [:index, :show]
48
+ end
49
+ end
9
50
  end
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,7 @@
1
+ const { environment } = require('@rails/webpacker')
2
+ const { VueLoaderPlugin } = require('vue-loader')
3
+ const vue = require('./loaders/vue')
4
+
5
+ environment.plugins.prepend('VueLoaderPlugin', new VueLoaderPlugin())
6
+ environment.loaders.prepend('vue', vue)
7
+ module.exports = environment
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ test: /\.vue(\.erb)?$/,
3
+ use: [{
4
+ loader: 'vue-loader'
5
+ }]
6
+ }
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,97 @@
1
+ # Note: You must restart bin/webpack-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ source_path: app/javascript
5
+ source_entry_path: packs
6
+ public_root_path: public
7
+ public_output_path: packs
8
+ cache_path: tmp/cache/webpacker
9
+ check_yarn_integrity: false
10
+ webpack_compile_output: true
11
+
12
+ # Additional paths webpack should lookup modules
13
+ # ['app/assets', 'engine/foo/app/assets']
14
+ resolved_paths: []
15
+
16
+ # Reload manifest.json on all requests so we reload latest compiled packs
17
+ cache_manifest: false
18
+
19
+ # Extract and emit a css file
20
+ extract_css: false
21
+
22
+ static_assets_extensions:
23
+ - .jpg
24
+ - .jpeg
25
+ - .png
26
+ - .gif
27
+ - .tiff
28
+ - .ico
29
+ - .svg
30
+ - .eot
31
+ - .otf
32
+ - .ttf
33
+ - .woff
34
+ - .woff2
35
+
36
+ extensions:
37
+ - .vue
38
+ - .mjs
39
+ - .js
40
+ - .sass
41
+ - .scss
42
+ - .css
43
+ - .module.sass
44
+ - .module.scss
45
+ - .module.css
46
+ - .png
47
+ - .svg
48
+ - .gif
49
+ - .jpeg
50
+ - .jpg
51
+
52
+ development:
53
+ <<: *default
54
+ compile: true
55
+
56
+ # Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
57
+ check_yarn_integrity: true
58
+
59
+ # Reference: https://webpack.js.org/configuration/dev-server/
60
+ dev_server:
61
+ https: false
62
+ host: localhost
63
+ port: 3035
64
+ public: localhost:3035
65
+ hmr: false
66
+ # Inline should be set to true if using HMR
67
+ inline: true
68
+ overlay: true
69
+ compress: true
70
+ disable_host_check: true
71
+ use_local_ip: false
72
+ quiet: false
73
+ pretty: false
74
+ headers:
75
+ 'Access-Control-Allow-Origin': '*'
76
+ watch_options:
77
+ ignored: '**/node_modules/**'
78
+
79
+
80
+ test:
81
+ <<: *default
82
+ compile: true
83
+
84
+ # Compile test packs to a separate directory
85
+ public_output_path: packs-test
86
+
87
+ production:
88
+ <<: *default
89
+
90
+ # Production depends on precompilation of packs prior to booting for performance.
91
+ compile: false
92
+
93
+ # Extract and emit a css file
94
+ extract_css: false
95
+
96
+ # Cache manifest.json for performance
97
+ cache_manifest: true
@@ -1,4 +1,4 @@
1
- class CreateTestTables < ActiveRecord::Migration[5.1]
1
+ class CreateTestTables < ActiveRecord::Migration[5.2]
2
2
  def change
3
3
  create_table :users do |t|
4
4
  # Devise
@@ -1,5 +1,5 @@
1
1
  # Migration responsible for creating a table with notifications
2
- class CreateActivityNotificationTables < ActiveRecord::Migration[5.1]
2
+ class CreateActivityNotificationTables < ActiveRecord::Migration[5.2]
3
3
  # Create tables
4
4
  def change
5
5
  create_table :notifications do |t|
@@ -12,7 +12,7 @@ class CreateActivityNotificationTables < ActiveRecord::Migration[5.1]
12
12
  t.text :parameters
13
13
  t.datetime :opened_at
14
14
 
15
- t.timestamps
15
+ t.timestamps null: false
16
16
  end
17
17
 
18
18
  create_table :subscriptions do |t|
@@ -26,7 +26,7 @@ class CreateActivityNotificationTables < ActiveRecord::Migration[5.1]
26
26
  t.datetime :unsubscribed_to_email_at
27
27
  t.text :optional_targets
28
28
 
29
- t.timestamps
29
+ t.timestamps null: false
30
30
  end
31
31
  add_index :subscriptions, [:target_type, :target_id, :key], unique: true
32
32
  end
@@ -0,0 +1,10 @@
1
+ class AddTokensToUsers < ActiveRecord::Migration[5.2]
2
+ def change
3
+ ## Required
4
+ add_column :users, :provider, :string, null: false, default: "email"
5
+ add_column :users, :uid, :string, null: false, default: ""
6
+
7
+ ## Tokens
8
+ add_column :users, :tokens, :text
9
+ end
10
+ end
@@ -10,51 +10,51 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 20160715050433) do
13
+ ActiveRecord::Schema.define(version: 2019_12_01_000000) do
14
14
 
15
15
  create_table "admins", force: :cascade do |t|
16
- t.integer "user_id"
17
- t.string "phone_number"
18
- t.string "slack_username"
19
- t.datetime "created_at"
20
- t.datetime "updated_at"
16
+ t.integer "user_id"
17
+ t.string "phone_number"
18
+ t.string "slack_username"
19
+ t.datetime "created_at", null: false
20
+ t.datetime "updated_at", null: false
21
21
  t.index ["user_id"], name: "index_admins_on_user_id"
22
22
  end
23
23
 
24
24
  create_table "articles", force: :cascade do |t|
25
- t.integer "user_id"
26
- t.string "title"
27
- t.string "body"
28
- t.datetime "created_at"
29
- t.datetime "updated_at"
25
+ t.integer "user_id"
26
+ t.string "title"
27
+ t.string "body"
28
+ t.datetime "created_at", null: false
29
+ t.datetime "updated_at", null: false
30
30
  t.index ["user_id"], name: "index_articles_on_user_id"
31
31
  end
32
32
 
33
33
  create_table "comments", force: :cascade do |t|
34
- t.integer "user_id"
35
- t.integer "article_id"
36
- t.string "body"
37
- t.datetime "created_at"
38
- t.datetime "updated_at"
34
+ t.integer "user_id"
35
+ t.integer "article_id"
36
+ t.string "body"
37
+ t.datetime "created_at", null: false
38
+ t.datetime "updated_at", null: false
39
39
  t.index ["article_id"], name: "index_comments_on_article_id"
40
40
  t.index ["user_id"], name: "index_comments_on_user_id"
41
41
  end
42
42
 
43
43
  create_table "notifications", force: :cascade do |t|
44
- t.string "target_type", null: false
45
- t.integer "target_id", null: false
46
- t.string "notifiable_type", null: false
47
- t.integer "notifiable_id", null: false
48
- t.string "key", null: false
49
- t.string "group_type"
50
- t.integer "group_id"
51
- t.integer "group_owner_id"
52
- t.string "notifier_type"
53
- t.integer "notifier_id"
54
- t.text "parameters"
44
+ t.string "target_type", null: false
45
+ t.integer "target_id", null: false
46
+ t.string "notifiable_type", null: false
47
+ t.integer "notifiable_id", null: false
48
+ t.string "key", null: false
49
+ t.string "group_type"
50
+ t.integer "group_id"
51
+ t.integer "group_owner_id"
52
+ t.string "notifier_type"
53
+ t.integer "notifier_id"
54
+ t.text "parameters"
55
55
  t.datetime "opened_at"
56
- t.datetime "created_at"
57
- t.datetime "updated_at"
56
+ t.datetime "created_at", null: false
57
+ t.datetime "updated_at", null: false
58
58
  t.index ["group_owner_id"], name: "index_notifications_on_group_owner_id"
59
59
  t.index ["group_type", "group_id"], name: "index_notifications_on_group_type_and_group_id"
60
60
  t.index ["notifiable_type", "notifiable_id"], name: "index_notifications_on_notifiable_type_and_notifiable_id"
@@ -63,32 +63,35 @@ ActiveRecord::Schema.define(version: 20160715050433) do
63
63
  end
64
64
 
65
65
  create_table "subscriptions", force: :cascade do |t|
66
- t.string "target_type", null: false
67
- t.integer "target_id", null: false
68
- t.string "key", null: false
69
- t.boolean "subscribing", default: true, null: false
70
- t.boolean "subscribing_to_email", default: true, null: false
66
+ t.string "target_type", null: false
67
+ t.integer "target_id", null: false
68
+ t.string "key", null: false
69
+ t.boolean "subscribing", default: true, null: false
70
+ t.boolean "subscribing_to_email", default: true, null: false
71
71
  t.datetime "subscribed_at"
72
72
  t.datetime "unsubscribed_at"
73
73
  t.datetime "subscribed_to_email_at"
74
74
  t.datetime "unsubscribed_to_email_at"
75
- t.text "optional_targets"
76
- t.datetime "created_at"
77
- t.datetime "updated_at"
75
+ t.text "optional_targets"
76
+ t.datetime "created_at", null: false
77
+ t.datetime "updated_at", null: false
78
78
  t.index ["key"], name: "index_subscriptions_on_key"
79
79
  t.index ["target_type", "target_id", "key"], name: "index_subscriptions_on_target_type_and_target_id_and_key", unique: true
80
80
  t.index ["target_type", "target_id"], name: "index_subscriptions_on_target_type_and_target_id"
81
81
  end
82
82
 
83
83
  create_table "users", force: :cascade do |t|
84
- t.string "email", default: "", null: false
85
- t.string "encrypted_password", default: "", null: false
86
- t.string "confirmation_token"
84
+ t.string "email", default: "", null: false
85
+ t.string "encrypted_password", default: "", null: false
86
+ t.string "confirmation_token"
87
87
  t.datetime "confirmed_at"
88
88
  t.datetime "confirmation_sent_at"
89
- t.string "name"
90
- t.datetime "created_at"
91
- t.datetime "updated_at"
89
+ t.string "name"
90
+ t.datetime "created_at", null: false
91
+ t.datetime "updated_at", null: false
92
+ t.string "provider", default: "email", null: false
93
+ t.string "uid", default: "", null: false
94
+ t.text "tokens"
92
95
  t.index ["email"], name: "index_users_on_email"
93
96
  end
94
97