activity_notification 2.0.0 → 2.1.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 (202) hide show
  1. checksums.yaml +4 -4
  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/.gitignore +10 -3
  6. data/.travis.yml +6 -5
  7. data/CHANGELOG.md +60 -0
  8. data/Gemfile +8 -3
  9. data/Procfile +1 -1
  10. data/README.md +153 -1510
  11. data/activity_notification.gemspec +4 -1
  12. data/app/channels/activity_notification/notification_api_channel.rb +12 -0
  13. data/app/channels/activity_notification/notification_api_with_devise_channel.rb +46 -0
  14. data/app/channels/activity_notification/notification_channel.rb +2 -2
  15. data/app/channels/activity_notification/notification_with_devise_channel.rb +2 -2
  16. data/app/controllers/activity_notification/apidocs_controller.rb +75 -0
  17. data/app/controllers/activity_notification/notifications_api_controller.rb +143 -0
  18. data/app/controllers/activity_notification/notifications_api_with_devise_controller.rb +7 -0
  19. data/app/controllers/activity_notification/notifications_controller.rb +79 -53
  20. data/app/controllers/activity_notification/subscriptions_api_controller.rb +197 -0
  21. data/app/controllers/activity_notification/subscriptions_api_with_devise_controller.rb +7 -0
  22. data/app/controllers/activity_notification/subscriptions_controller.rb +78 -69
  23. data/app/views/activity_notification/notifications/default/_default.html.erb +18 -18
  24. data/app/views/activity_notification/notifications/default/_default_without_grouping.html.erb +14 -14
  25. data/app/views/activity_notification/notifications/default/index.html.erb +6 -6
  26. data/app/views/activity_notification/optional_targets/default/action_cable_channel/_default.html.erb +176 -0
  27. data/app/views/activity_notification/subscriptions/default/_form.html.erb +1 -1
  28. data/app/views/activity_notification/subscriptions/default/_notification_keys.html.erb +3 -31
  29. data/app/views/activity_notification/subscriptions/default/_subscription.html.erb +7 -7
  30. data/app/views/activity_notification/subscriptions/default/index.html.erb +11 -7
  31. data/bin/deploy_on_heroku.sh +3 -1
  32. data/docs/CODE_OF_CONDUCT.md +76 -0
  33. data/docs/CONTRIBUTING.md +36 -0
  34. data/docs/Functions.md +1130 -0
  35. data/docs/Setup.md +801 -0
  36. data/docs/Testing.md +148 -0
  37. data/gemfiles/Gemfile.rails-4.2 +5 -1
  38. data/gemfiles/Gemfile.rails-5.0 +6 -1
  39. data/gemfiles/Gemfile.rails-5.1 +6 -1
  40. data/gemfiles/Gemfile.rails-5.2 +6 -1
  41. data/gemfiles/{Gemfile.rails-6.0.rc → Gemfile.rails-6.0} +6 -5
  42. data/lib/activity_notification.rb +13 -0
  43. data/lib/activity_notification/apis/notification_api.rb +37 -93
  44. data/lib/activity_notification/apis/subscription_api.rb +20 -8
  45. data/lib/activity_notification/apis/swagger.rb +6 -0
  46. data/lib/activity_notification/common.rb +4 -1
  47. data/lib/activity_notification/config.rb +41 -21
  48. data/lib/activity_notification/controllers/common_api_controller.rb +30 -0
  49. data/lib/activity_notification/controllers/common_controller.rb +45 -21
  50. data/lib/activity_notification/controllers/concerns/swagger/error_responses.rb +55 -0
  51. data/lib/activity_notification/controllers/concerns/swagger/notifications_api.rb +273 -0
  52. data/lib/activity_notification/controllers/concerns/swagger/notifications_parameters.rb +92 -0
  53. data/lib/activity_notification/controllers/concerns/swagger/subscriptions_api.rb +405 -0
  54. data/lib/activity_notification/controllers/concerns/swagger/subscriptions_parameters.rb +50 -0
  55. data/lib/activity_notification/controllers/devise_authentication_controller.rb +7 -6
  56. data/lib/activity_notification/gem_version.rb +14 -0
  57. data/lib/activity_notification/helpers/errors.rb +2 -0
  58. data/lib/activity_notification/helpers/view_helpers.rb +4 -0
  59. data/lib/activity_notification/mailers/helpers.rb +17 -10
  60. data/lib/activity_notification/models/concerns/notifiable.rb +31 -15
  61. data/lib/activity_notification/models/concerns/subscriber.rb +12 -1
  62. data/lib/activity_notification/models/concerns/swagger/error_schema.rb +36 -0
  63. data/lib/activity_notification/models/concerns/swagger/notification_schema.rb +209 -0
  64. data/lib/activity_notification/models/concerns/swagger/subscription_schema.rb +162 -0
  65. data/lib/activity_notification/models/concerns/target.rb +36 -10
  66. data/lib/activity_notification/models/notification.rb +1 -0
  67. data/lib/activity_notification/models/subscription.rb +1 -0
  68. data/lib/activity_notification/optional_targets/action_cable_api_channel.rb +69 -0
  69. data/lib/activity_notification/optional_targets/action_cable_channel.rb +68 -0
  70. data/lib/activity_notification/optional_targets/base.rb +7 -13
  71. data/lib/activity_notification/orm/active_record/notification.rb +17 -1
  72. data/lib/activity_notification/orm/active_record/subscription.rb +1 -1
  73. data/lib/activity_notification/orm/dynamoid.rb +38 -3
  74. data/lib/activity_notification/orm/dynamoid/extension.rb +79 -1
  75. data/lib/activity_notification/orm/dynamoid/notification.rb +49 -14
  76. data/lib/activity_notification/orm/dynamoid/subscription.rb +2 -2
  77. data/lib/activity_notification/orm/mongoid.rb +32 -3
  78. data/lib/activity_notification/orm/mongoid/notification.rb +24 -6
  79. data/lib/activity_notification/orm/mongoid/subscription.rb +1 -1
  80. data/lib/activity_notification/rails/routes.rb +132 -48
  81. data/lib/activity_notification/renderable.rb +13 -2
  82. data/lib/activity_notification/roles/acts_as_notifiable.rb +39 -20
  83. data/lib/activity_notification/version.rb +1 -1
  84. data/lib/generators/activity_notification/controllers_generator.rb +2 -1
  85. data/lib/generators/templates/activity_notification.rb +8 -0
  86. data/lib/generators/templates/controllers/notifications_api_controller.rb +31 -0
  87. data/lib/generators/templates/controllers/notifications_api_with_devise_controller.rb +31 -0
  88. data/lib/generators/templates/controllers/notifications_controller.rb +1 -37
  89. data/lib/generators/templates/controllers/notifications_with_devise_controller.rb +1 -45
  90. data/lib/generators/templates/controllers/subscriptions_api_controller.rb +61 -0
  91. data/lib/generators/templates/controllers/subscriptions_api_with_devise_controller.rb +61 -0
  92. data/lib/generators/templates/controllers/subscriptions_controller.rb +14 -37
  93. data/lib/generators/templates/controllers/subscriptions_with_devise_controller.rb +14 -45
  94. data/lib/generators/templates/models/README +8 -4
  95. data/lib/generators/templates/models/notification.rb +1 -1
  96. data/lib/generators/templates/models/subscription.rb +1 -1
  97. data/package.json +8 -0
  98. data/spec/channels/notification_api_channel_shared_examples.rb +59 -0
  99. data/spec/channels/notification_api_channel_spec.rb +51 -0
  100. data/spec/channels/notification_api_with_devise_channel_spec.rb +78 -0
  101. data/spec/concerns/apis/notification_api_spec.rb +38 -3
  102. data/spec/concerns/models/notifiable_spec.rb +82 -18
  103. data/spec/concerns/models/subscriber_spec.rb +13 -16
  104. data/spec/concerns/models/target_spec.rb +32 -0
  105. data/spec/concerns/renderable_spec.rb +2 -2
  106. data/spec/config_spec.rb +26 -15
  107. data/spec/controllers/controller_spec_utility.rb +136 -0
  108. data/spec/controllers/notifications_api_controller_shared_examples.rb +506 -0
  109. data/spec/controllers/notifications_api_controller_spec.rb +19 -0
  110. data/spec/controllers/notifications_api_with_devise_controller_spec.rb +60 -0
  111. data/spec/controllers/notifications_controller_shared_examples.rb +54 -79
  112. data/spec/controllers/notifications_controller_spec.rb +1 -2
  113. data/spec/controllers/notifications_with_devise_controller_spec.rb +3 -12
  114. data/spec/controllers/subscriptions_api_controller_shared_examples.rb +750 -0
  115. data/spec/controllers/subscriptions_api_controller_spec.rb +19 -0
  116. data/spec/controllers/subscriptions_api_with_devise_controller_spec.rb +60 -0
  117. data/spec/controllers/subscriptions_controller_shared_examples.rb +94 -121
  118. data/spec/controllers/subscriptions_controller_spec.rb +1 -2
  119. data/spec/controllers/subscriptions_with_devise_controller_spec.rb +3 -12
  120. data/spec/helpers/view_helpers_spec.rb +4 -11
  121. data/spec/mailers/mailer_spec.rb +41 -0
  122. data/spec/models/notification_spec.rb +17 -0
  123. data/spec/models/subscription_spec.rb +8 -13
  124. data/spec/optional_targets/action_cable_api_channel_spec.rb +37 -0
  125. data/spec/optional_targets/action_cable_channel_spec.rb +44 -0
  126. data/spec/optional_targets/amazon_sns_spec.rb +0 -2
  127. data/spec/optional_targets/slack_spec.rb +0 -2
  128. data/spec/rails_app/Rakefile +9 -0
  129. data/spec/rails_app/app/assets/config/manifest.js +3 -0
  130. data/spec/rails_app/app/assets/images/.keep +0 -0
  131. data/spec/rails_app/app/controllers/admins_controller.rb +21 -0
  132. data/spec/rails_app/app/controllers/application_controller.rb +1 -1
  133. data/spec/rails_app/app/controllers/articles_controller.rb +6 -3
  134. data/spec/rails_app/app/controllers/spa_controller.rb +7 -0
  135. data/spec/rails_app/app/controllers/users/notifications_controller.rb +0 -65
  136. data/spec/rails_app/app/controllers/users/notifications_with_devise_controller.rb +0 -73
  137. data/spec/rails_app/app/controllers/users/subscriptions_controller.rb +0 -77
  138. data/spec/rails_app/app/controllers/users/subscriptions_with_devise_controller.rb +0 -85
  139. data/spec/rails_app/app/controllers/users_controller.rb +26 -0
  140. data/spec/rails_app/app/javascript/App.vue +40 -0
  141. data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +82 -0
  142. data/spec/rails_app/app/javascript/components/Top.vue +98 -0
  143. data/spec/rails_app/app/javascript/components/notifications/Index.vue +200 -0
  144. data/spec/rails_app/app/javascript/components/notifications/Notification.vue +133 -0
  145. data/spec/rails_app/app/javascript/components/notifications/NotificationContent.vue +122 -0
  146. data/spec/rails_app/app/javascript/components/subscriptions/Index.vue +279 -0
  147. data/spec/rails_app/app/javascript/components/subscriptions/NewSubscription.vue +112 -0
  148. data/spec/rails_app/app/javascript/components/subscriptions/NotificationKey.vue +141 -0
  149. data/spec/rails_app/app/javascript/components/subscriptions/Subscription.vue +226 -0
  150. data/spec/rails_app/app/javascript/config/development.js +5 -0
  151. data/spec/rails_app/app/javascript/config/environment.js +7 -0
  152. data/spec/rails_app/app/javascript/config/production.js +5 -0
  153. data/spec/rails_app/app/javascript/config/test.js +5 -0
  154. data/spec/rails_app/app/javascript/packs/application.js +18 -0
  155. data/spec/rails_app/app/javascript/packs/spa.js +14 -0
  156. data/spec/rails_app/app/javascript/router/index.js +73 -0
  157. data/spec/rails_app/app/javascript/store/index.js +37 -0
  158. data/spec/rails_app/app/models/admin.rb +16 -15
  159. data/spec/rails_app/app/models/article.rb +26 -21
  160. data/spec/rails_app/app/models/comment.rb +24 -71
  161. data/spec/rails_app/app/models/dummy/dummy_group.rb +8 -0
  162. data/spec/rails_app/app/models/dummy/dummy_notifiable_target.rb +8 -0
  163. data/spec/rails_app/app/models/user.rb +44 -20
  164. data/spec/rails_app/app/views/activity_notification/notifications/default/article/_update.html.erb +146 -0
  165. data/spec/rails_app/app/views/articles/index.html.erb +51 -7
  166. data/spec/rails_app/app/views/articles/show.html.erb +1 -1
  167. data/spec/rails_app/app/views/layouts/_header.html.erb +8 -10
  168. data/spec/rails_app/app/views/spa/index.html.erb +2 -0
  169. data/spec/rails_app/babel.config.js +72 -0
  170. data/spec/rails_app/bin/webpack +18 -0
  171. data/spec/rails_app/bin/webpack-dev-server +18 -0
  172. data/spec/rails_app/config/application.rb +18 -2
  173. data/spec/rails_app/config/dynamoid.rb +11 -3
  174. data/spec/rails_app/config/environment.rb +2 -1
  175. data/spec/rails_app/config/environments/development.rb +5 -0
  176. data/spec/rails_app/config/environments/production.rb +6 -0
  177. data/spec/rails_app/config/environments/test.rb +5 -0
  178. data/spec/rails_app/config/initializers/activity_notification.rb +11 -3
  179. data/spec/rails_app/config/initializers/copy_it.aws.rb.template +6 -0
  180. data/spec/rails_app/config/initializers/devise_token_auth.rb +55 -0
  181. data/spec/rails_app/config/initializers/mysql.rb +9 -0
  182. data/spec/rails_app/config/locales/activity_notification.en.yml +2 -2
  183. data/spec/rails_app/config/routes.rb +37 -1
  184. data/spec/rails_app/config/webpack/development.js +5 -0
  185. data/spec/rails_app/config/webpack/environment.js +7 -0
  186. data/spec/rails_app/config/webpack/loaders/vue.js +6 -0
  187. data/spec/rails_app/config/webpack/production.js +5 -0
  188. data/spec/rails_app/config/webpack/test.js +5 -0
  189. data/spec/rails_app/config/webpacker.yml +97 -0
  190. data/spec/rails_app/db/migrate/20191201000000_add_tokens_to_users.rb +10 -0
  191. data/spec/rails_app/db/schema.rb +4 -1
  192. data/spec/rails_app/db/seeds.rb +10 -2
  193. data/spec/rails_app/lib/custom_optional_targets/raise_error.rb +14 -0
  194. data/spec/rails_app/package.json +23 -0
  195. data/spec/rails_app/postcss.config.js +12 -0
  196. data/spec/roles/acts_as_group_spec.rb +0 -2
  197. data/spec/roles/acts_as_notifiable_spec.rb +6 -8
  198. data/spec/roles/acts_as_notifier_spec.rb +0 -2
  199. data/spec/roles/acts_as_target_spec.rb +0 -4
  200. data/spec/spec_helper.rb +7 -15
  201. data/spec/version_spec.rb +31 -0
  202. metadata +191 -13
@@ -1,4 +1,26 @@
1
- <% if @exists_user_notification_routes %>
1
+ <% if @exists_notifications_routes %>
2
+ <section>
3
+ <h1>Authentecated User</h1>
4
+ <div class="list_wrapper">
5
+ <div class="list_image"></div>
6
+ <div class="list_description_wrapper">
7
+ <p class="list_description">
8
+ <% if user_signed_in? %>
9
+ <span><%= current_user.name %></span> · <%= current_user.email %> · <%= link_to 'Logout', destroy_user_session_path, method: :delete %><br>
10
+ <% else %>
11
+ <span>Not logged in</span> · <%= link_to 'Login', new_user_session_path %><br>
12
+ <% end %>
13
+ <%= link_to 'Notifications', notifications_path %> /
14
+ <% if User.subscription_enabled? %>
15
+ <%= link_to 'Subscriptions', subscriptions_path %>
16
+ <% end %>
17
+ </p>
18
+ </div>
19
+ </div>
20
+ </section>
21
+ <% end %>
22
+
23
+ <% if @exists_user_notifications_routes %>
2
24
  <section>
3
25
  <h1>Listing Users</h1>
4
26
  <% User.all.each do |user| %>
@@ -7,7 +29,7 @@
7
29
  <div class="list_description_wrapper">
8
30
  <p class="list_description">
9
31
  <span><%= user.name %></span> · <%= user.email %><br>
10
- <%= link_to 'Notifications', user_notifications_path(user) %>
32
+ <%= link_to 'Notifications', user_notifications_path(user) %> /
11
33
  <% if User.subscription_enabled? %>
12
34
  <%= link_to 'Subscriptions', user_subscriptions_path(user) %>
13
35
  <% end %>
@@ -18,7 +40,29 @@
18
40
  </section>
19
41
  <% end %>
20
42
 
21
- <% if @exists_admin_notification_routes %>
43
+ <% if @exists_admins_notifications_routes %>
44
+ <section>
45
+ <h1>Authentecated User as Admin</h1>
46
+ <div class="list_wrapper">
47
+ <div class="list_image"></div>
48
+ <div class="list_description_wrapper">
49
+ <p class="list_description">
50
+ <% if user_signed_in? %>
51
+ <span><%= current_user.name %></span> · <%= current_user.email %> <span><%= current_user.admin? ? "(admin)" : "(not admin)" %></span><br>
52
+ <% else %>
53
+ <span>Not logged in</span> · <%= link_to 'Login', new_user_session_path %><br>
54
+ <% end %>
55
+ <%= link_to 'Notifications', admins_notifications_path %> /
56
+ <% if User.subscription_enabled? %>
57
+ <%= link_to 'Subscriptions', admins_subscriptions_path %>
58
+ <% end %>
59
+ </p>
60
+ </div>
61
+ </div>
62
+ </section>
63
+ <% end %>
64
+
65
+ <% if @exists_admin_notifications_routes %>
22
66
  <section>
23
67
  <h1>Listing Admins</h1>
24
68
  <% Admin.all.each do |admin| %>
@@ -27,7 +71,7 @@
27
71
  <div class="list_description_wrapper">
28
72
  <p class="list_description">
29
73
  <span><%= admin.user.name %></span> · <%= admin.user.email %><br>
30
- <%= link_to 'Notifications', admin_notifications_path(admin) %>
74
+ <%= link_to 'Notifications', admin_notifications_path(admin) %> /
31
75
  <% if Admin.subscription_enabled? %>
32
76
  <%= link_to 'Subscriptions', admin_subscriptions_path(admin) %>
33
77
  <% end %>
@@ -59,9 +103,9 @@
59
103
  <% if user_signed_in? and article.author?(current_user) %>
60
104
  <%= link_to 'Edit Article', edit_article_path(article), class: "gray_button" %>
61
105
  <% end %>
62
- <% if user_signed_in? and (article.author?(current_user) or current_user.admin?) %>
63
- <%= link_to 'Destroy Article', article, method: :delete, data: { confirm: 'Are you sure?' }, class: "gray_button" %>
64
- <% end %>
106
+ <%# if user_signed_in? and (article.author?(current_user) or current_user.admin?) %>
107
+ <%#= link_to 'Destroy Article', article, method: :delete, data: { confirm: 'Are you sure?' }, class: "gray_button" %>
108
+ <%# end %>
65
109
  </div>
66
110
  </div>
67
111
  </div>
@@ -9,7 +9,7 @@
9
9
  </p>
10
10
  <div class="list_button_wrapper">
11
11
  <%= link_to 'Edit Article', edit_article_path(@article), class: "gray_button" %>
12
- <%= link_to 'Destroy Article', @article, method: :delete, data: { confirm: 'Are you sure?' }, class: "gray_button" %>
12
+ <%#= link_to 'Destroy Article', @article, method: :delete, data: { confirm: 'Are you sure?' }, class: "gray_button" %>
13
13
  </div>
14
14
  </div>
15
15
  </div>
@@ -30,18 +30,16 @@
30
30
  <%#= render_notifications_of current_user, fallback: :default_without_grouping, index_content: :with_attributes, with_group_members: true %>
31
31
  <% end %>
32
32
  </div>
33
- <% if user_signed_in? and current_user.admin? and respond_to?('admins_notifications_path') %>
34
- <div class="header_menu_wrapper">
35
- <p>
36
- <%= link_to "Admin notifications", admins_notifications_path %> /
37
- <%= link_to "subscriptions", admins_subscriptions_path %>
38
- </p>
39
- </div>
40
- <% end %>
41
33
  <div class="header_menu_wrapper">
42
34
  <p>
43
- <%= link_to 'Preview email', "/rails/mailers" %>
44
- <%= " · " unless user_signed_in? %>
35
+ <%= link_to 'Preview Email', "/rails/mailers" %>
36
+ <%= " · " if !user_signed_in? or (current_user.admin? and respond_to?('admins_notifications_path')) %>
37
+ </p>
38
+ </div>
39
+ <div class="header_menu_wrapper">
40
+ <p>
41
+ <%= link_to 'SPA', "/spa/" %>
42
+ <%= " · " %>
45
43
  </p>
46
44
  </div>
47
45
  </div>
@@ -0,0 +1,2 @@
1
+ <div id='spa'/>
2
+ <%= javascript_pack_tag 'spa' %>
@@ -0,0 +1,72 @@
1
+ module.exports = function(api) {
2
+ var validEnv = ['development', 'test', 'production']
3
+ var currentEnv = api.env()
4
+ var isDevelopmentEnv = api.env('development')
5
+ var isProductionEnv = api.env('production')
6
+ var isTestEnv = api.env('test')
7
+
8
+ if (!validEnv.includes(currentEnv)) {
9
+ throw new Error(
10
+ 'Please specify a valid `NODE_ENV` or ' +
11
+ '`BABEL_ENV` environment variables. Valid values are "development", ' +
12
+ '"test", and "production". Instead, received: ' +
13
+ JSON.stringify(currentEnv) +
14
+ '.'
15
+ )
16
+ }
17
+
18
+ return {
19
+ presets: [
20
+ isTestEnv && [
21
+ '@babel/preset-env',
22
+ {
23
+ targets: {
24
+ node: 'current'
25
+ }
26
+ }
27
+ ],
28
+ (isProductionEnv || isDevelopmentEnv) && [
29
+ '@babel/preset-env',
30
+ {
31
+ forceAllTransforms: true,
32
+ useBuiltIns: 'entry',
33
+ corejs: 3,
34
+ modules: false,
35
+ exclude: ['transform-typeof-symbol']
36
+ }
37
+ ]
38
+ ].filter(Boolean),
39
+ plugins: [
40
+ 'babel-plugin-macros',
41
+ '@babel/plugin-syntax-dynamic-import',
42
+ isTestEnv && 'babel-plugin-dynamic-import-node',
43
+ '@babel/plugin-transform-destructuring',
44
+ [
45
+ '@babel/plugin-proposal-class-properties',
46
+ {
47
+ loose: true
48
+ }
49
+ ],
50
+ [
51
+ '@babel/plugin-proposal-object-rest-spread',
52
+ {
53
+ useBuiltIns: true
54
+ }
55
+ ],
56
+ [
57
+ '@babel/plugin-transform-runtime',
58
+ {
59
+ helpers: false,
60
+ regenerator: true,
61
+ corejs: false
62
+ }
63
+ ],
64
+ [
65
+ '@babel/plugin-transform-regenerator',
66
+ {
67
+ async: false
68
+ }
69
+ ]
70
+ ].filter(Boolean)
71
+ }
72
+ }
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= "development"
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "bundler/setup"
11
+
12
+ require "webpacker"
13
+ require "webpacker/webpack_runner"
14
+
15
+ APP_ROOT = File.expand_path("..", __dir__)
16
+ Dir.chdir(APP_ROOT) do
17
+ Webpacker::WebpackRunner.run(ARGV)
18
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= "development"
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "bundler/setup"
11
+
12
+ require "webpacker"
13
+ require "webpacker/dev_server_runner"
14
+
15
+ APP_ROOT = File.expand_path("..", __dir__)
16
+ Dir.chdir(APP_ROOT) do
17
+ Webpacker::DevServerRunner.run(ARGV)
18
+ end
@@ -4,9 +4,10 @@ require File.expand_path('../boot', __FILE__)
4
4
  if ENV['AN_ORM'] == 'mongoid'
5
5
  require 'mongoid'
6
6
  require 'rails'
7
- if Rails.env != 'test'
7
+ unless Rails.env.test?
8
8
  Mongoid.load!(File.expand_path("config/mongoid.yml"), :development)
9
9
  end
10
+ # Load dynamoid configuration if necessary:
10
11
  elsif ENV['AN_ORM'] == 'dynamoid'
11
12
  require 'dynamoid'
12
13
  require 'rails'
@@ -14,7 +15,9 @@ elsif ENV['AN_ORM'] == 'dynamoid'
14
15
  end
15
16
 
16
17
  # Pick the frameworks you want:
17
- unless ENV['AN_ORM'] == 'mongoid' && ENV['AN_TEST_DB'] == 'mongodb'
18
+ if ENV['AN_ORM'] == 'mongoid' && ENV['AN_TEST_DB'] == 'mongodb'
19
+ require "mongoid/railtie"
20
+ else
18
21
  require "active_record/railtie"
19
22
  end
20
23
  require "action_controller/railtie"
@@ -35,6 +38,19 @@ module Dummy
35
38
  if Rails::VERSION::MAJOR >= 5 && Rails::VERSION::MINOR >= 2 && ENV['AN_TEST_DB'] != 'mongodb'
36
39
  config.active_record.sqlite3.represent_boolean_as_integer = true
37
40
  end
41
+
42
+ # Configure CORS for API mode
43
+ if defined?(Rack::Cors)
44
+ config.middleware.insert_before 0, Rack::Cors do
45
+ allow do
46
+ origins '*'
47
+ resource '*',
48
+ headers: :any,
49
+ expose: ['access-token', 'client', 'uid'],
50
+ methods: [:get, :post, :put, :delete]
51
+ end
52
+ end
53
+ end
38
54
  end
39
55
  end
40
56
 
@@ -1,5 +1,13 @@
1
1
  Dynamoid.configure do |config|
2
- config.namespace = "activity_notification_#{Rails.env}"
3
- config.endpoint = 'http://localhost:8000'
4
- # config.store_datetime_as_string = true
2
+ config.namespace = ENV['AN_NO_DYNAMODB_NAMESPACE'] ? "" : "activity_notification_#{Rails.env}"
3
+ # TODO Update Dynamoid v3.4.0+
4
+ # config.capacity_mode = :on_demand
5
+ config.read_capacity = 5
6
+ config.write_capacity = 5
7
+ unless Rails.env.production?
8
+ config.endpoint = 'http://localhost:8000'
9
+ end
10
+ unless Rails.env.test?
11
+ config.store_datetime_as_string = true
12
+ end
5
13
  end
@@ -1,8 +1,9 @@
1
1
  # Load the Rails application.
2
2
  require File.expand_path('../application', __FILE__)
3
3
 
4
- # Demo application uses Devise
4
+ # Demo application uses Devise and Devise Token Auth
5
5
  require 'devise'
6
+ require 'devise_token_auth'
6
7
 
7
8
  # Initialize the Rails application.
8
9
  Rails.application.initialize!
@@ -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
@@ -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
@@ -54,4 +54,9 @@ Rails.application.configure do
54
54
 
55
55
  # Set default_url_options for devise and notification email.
56
56
  config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
57
+
58
+ # Specifies delivery job for mail
59
+ if Rails::VERSION::MAJOR >= 6
60
+ config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
61
+ end
57
62
  end
@@ -10,10 +10,10 @@ ActivityNotification.configure do |config|
10
10
  config.orm = ENV['AN_ORM'].to_sym
11
11
 
12
12
  # Configure table name to store notification data.
13
- config.notification_table_name = "notifications"
13
+ config.notification_table_name = ENV['AN_NOTIFICATION_TABLE_NAME'] || "notifications"
14
14
 
15
15
  # Configure table name to store subscription data.
16
- config.subscription_table_name = "subscriptions"
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.
@@ -64,13 +64,18 @@ ActivityNotification.configure do |config|
64
64
 
65
65
  # Configure if activity_notification stores notificaion records including associated records like target and notifiable..
66
66
  # This store_with_associated_records option can be set true only when you use mongoid or dynamoid ORM.
67
- config.store_with_associated_records = false
67
+ config.store_with_associated_records = (config.orm != :active_record)
68
68
 
69
69
  # Configure if WebSocket subscription using ActionCable is enabled.
70
70
  # Note that you can configure them for each model by acts_as roles.
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,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