activity_notification 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -29
  3. data/app/jobs/activity_notification/cascading_notification_job.rb +123 -0
  4. data/docs/Functions.md +202 -12
  5. data/docs/Setup.md +34 -2
  6. data/docs/Testing.md +12 -1
  7. data/lib/activity_notification/apis/cascading_notification_api.rb +208 -0
  8. data/lib/activity_notification/apis/notification_api.rb +3 -0
  9. data/lib/activity_notification/config.rb +10 -0
  10. data/lib/activity_notification/mailers/helpers.rb +27 -1
  11. data/lib/activity_notification/models/concerns/swagger/subscription_schema.rb +1 -1
  12. data/lib/activity_notification/version.rb +1 -1
  13. data/lib/generators/templates/activity_notification.rb +8 -0
  14. metadata +45 -481
  15. data/.codeclimate.yml +0 -33
  16. data/.coveralls.yml +0 -1
  17. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -22
  18. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -17
  19. data/.github/pull_request_template.md +0 -13
  20. data/.github/workflows/build.yml +0 -101
  21. data/.gitignore +0 -74
  22. data/.rspec +0 -3
  23. data/.rubocop.yml +0 -1157
  24. data/.yardopts +0 -6
  25. data/CHANGELOG.md +0 -439
  26. data/Gemfile +0 -31
  27. data/Procfile +0 -2
  28. data/Rakefile +0 -28
  29. data/activity_notification.gemspec +0 -44
  30. data/ai-curated-specs/issues/172/design.md +0 -220
  31. data/ai-curated-specs/issues/172/tasks.md +0 -326
  32. data/ai-curated-specs/issues/188/design.md +0 -227
  33. data/ai-curated-specs/issues/188/requirements.md +0 -78
  34. data/ai-curated-specs/issues/188/tasks.md +0 -203
  35. data/ai-curated-specs/issues/188/upstream-contributions.md +0 -592
  36. data/ai-curated-specs/issues/50/design.md +0 -235
  37. data/ai-curated-specs/issues/50/requirements.md +0 -49
  38. data/ai-curated-specs/issues/50/tasks.md +0 -232
  39. data/bin/_dynamodblocal +0 -4
  40. data/bin/bundle_update.sh +0 -7
  41. data/bin/deploy_on_heroku.sh +0 -16
  42. data/bin/install_dynamodblocal.sh +0 -5
  43. data/bin/start_dynamodblocal.sh +0 -47
  44. data/bin/stop_dynamodblocal.sh +0 -34
  45. data/gemfiles/Gemfile.rails-5.0 +0 -25
  46. data/gemfiles/Gemfile.rails-5.1 +0 -25
  47. data/gemfiles/Gemfile.rails-5.2 +0 -24
  48. data/gemfiles/Gemfile.rails-6.0 +0 -23
  49. data/gemfiles/Gemfile.rails-6.1 +0 -22
  50. data/gemfiles/Gemfile.rails-7.0 +0 -25
  51. data/gemfiles/Gemfile.rails-7.1 +0 -23
  52. data/gemfiles/Gemfile.rails-7.2 +0 -23
  53. data/gemfiles/Gemfile.rails-8.0 +0 -24
  54. data/package.json +0 -8
  55. data/spec/channels/notification_api_channel_shared_examples.rb +0 -59
  56. data/spec/channels/notification_api_channel_spec.rb +0 -49
  57. data/spec/channels/notification_api_with_devise_channel_spec.rb +0 -76
  58. data/spec/channels/notification_channel_shared_examples.rb +0 -59
  59. data/spec/channels/notification_channel_spec.rb +0 -48
  60. data/spec/channels/notification_with_devise_channel_spec.rb +0 -97
  61. data/spec/concerns/apis/notification_api_spec.rb +0 -1627
  62. data/spec/concerns/apis/subscription_api_spec.rb +0 -474
  63. data/spec/concerns/common_spec.rb +0 -213
  64. data/spec/concerns/models/group_spec.rb +0 -61
  65. data/spec/concerns/models/notifiable_spec.rb +0 -782
  66. data/spec/concerns/models/notifier_spec.rb +0 -71
  67. data/spec/concerns/models/subscriber_spec.rb +0 -800
  68. data/spec/concerns/models/target_spec.rb +0 -1285
  69. data/spec/concerns/renderable_spec.rb +0 -129
  70. data/spec/config_spec.rb +0 -85
  71. data/spec/controllers/common_controller_spec.rb +0 -25
  72. data/spec/controllers/controller_spec_utility.rb +0 -100
  73. data/spec/controllers/dummy_common_controller.rb +0 -5
  74. data/spec/controllers/notifications_api_controller_shared_examples.rb +0 -619
  75. data/spec/controllers/notifications_api_controller_spec.rb +0 -19
  76. data/spec/controllers/notifications_api_with_devise_controller_spec.rb +0 -60
  77. data/spec/controllers/notifications_controller_shared_examples.rb +0 -743
  78. data/spec/controllers/notifications_controller_spec.rb +0 -11
  79. data/spec/controllers/notifications_with_devise_controller_spec.rb +0 -97
  80. data/spec/controllers/subscriptions_api_controller_shared_examples.rb +0 -750
  81. data/spec/controllers/subscriptions_api_controller_spec.rb +0 -19
  82. data/spec/controllers/subscriptions_api_with_devise_controller_spec.rb +0 -60
  83. data/spec/controllers/subscriptions_controller_shared_examples.rb +0 -946
  84. data/spec/controllers/subscriptions_controller_spec.rb +0 -11
  85. data/spec/controllers/subscriptions_with_devise_controller_spec.rb +0 -97
  86. data/spec/factories/admins.rb +0 -5
  87. data/spec/factories/articles.rb +0 -5
  88. data/spec/factories/comments.rb +0 -6
  89. data/spec/factories/dummy/dummy_group.rb +0 -4
  90. data/spec/factories/dummy/dummy_notifiable.rb +0 -4
  91. data/spec/factories/dummy/dummy_notifier.rb +0 -4
  92. data/spec/factories/dummy/dummy_subscriber.rb +0 -4
  93. data/spec/factories/dummy/dummy_target.rb +0 -4
  94. data/spec/factories/notifications.rb +0 -7
  95. data/spec/factories/subscriptions.rb +0 -8
  96. data/spec/factories/users.rb +0 -11
  97. data/spec/generators/controllers_generator_spec.rb +0 -85
  98. data/spec/generators/install_generator_spec.rb +0 -43
  99. data/spec/generators/migration/migration_generator_spec.rb +0 -66
  100. data/spec/generators/models_generator_spec.rb +0 -96
  101. data/spec/generators/views_generator_spec.rb +0 -195
  102. data/spec/helpers/polymorphic_helpers_spec.rb +0 -89
  103. data/spec/helpers/view_helpers_spec.rb +0 -547
  104. data/spec/jobs/notification_resilience_job_spec.rb +0 -167
  105. data/spec/jobs/notify_all_job_spec.rb +0 -23
  106. data/spec/jobs/notify_job_spec.rb +0 -23
  107. data/spec/jobs/notify_to_job_spec.rb +0 -23
  108. data/spec/mailers/mailer_spec.rb +0 -214
  109. data/spec/mailers/notification_resilience_spec.rb +0 -263
  110. data/spec/models/dummy/dummy_group_spec.rb +0 -10
  111. data/spec/models/dummy/dummy_notifiable_spec.rb +0 -10
  112. data/spec/models/dummy/dummy_notifier_spec.rb +0 -10
  113. data/spec/models/dummy/dummy_subscriber_spec.rb +0 -8
  114. data/spec/models/dummy/dummy_target_spec.rb +0 -10
  115. data/spec/models/notification_spec.rb +0 -472
  116. data/spec/models/subscription_spec.rb +0 -215
  117. data/spec/optional_targets/action_cable_api_channel_spec.rb +0 -34
  118. data/spec/optional_targets/action_cable_channel_spec.rb +0 -41
  119. data/spec/optional_targets/amazon_sns_spec.rb +0 -47
  120. data/spec/optional_targets/base_spec.rb +0 -45
  121. data/spec/optional_targets/slack_spec.rb +0 -44
  122. data/spec/orm/dynamoid_spec.rb +0 -115
  123. data/spec/rails_app/Rakefile +0 -15
  124. data/spec/rails_app/app/assets/config/manifest.js +0 -3
  125. data/spec/rails_app/app/assets/images/.keep +0 -0
  126. data/spec/rails_app/app/assets/javascripts/application.js +0 -3
  127. data/spec/rails_app/app/assets/javascripts/cable.js +0 -12
  128. data/spec/rails_app/app/assets/stylesheets/application.css +0 -15
  129. data/spec/rails_app/app/assets/stylesheets/reset.css +0 -85
  130. data/spec/rails_app/app/assets/stylesheets/style.css +0 -244
  131. data/spec/rails_app/app/controllers/admins_controller.rb +0 -21
  132. data/spec/rails_app/app/controllers/application_controller.rb +0 -5
  133. data/spec/rails_app/app/controllers/articles_controller.rb +0 -67
  134. data/spec/rails_app/app/controllers/comments_controller.rb +0 -36
  135. data/spec/rails_app/app/controllers/concerns/.keep +0 -0
  136. data/spec/rails_app/app/controllers/spa_controller.rb +0 -7
  137. data/spec/rails_app/app/controllers/users/notifications_controller.rb +0 -2
  138. data/spec/rails_app/app/controllers/users/notifications_with_devise_controller.rb +0 -2
  139. data/spec/rails_app/app/controllers/users/subscriptions_controller.rb +0 -2
  140. data/spec/rails_app/app/controllers/users/subscriptions_with_devise_controller.rb +0 -2
  141. data/spec/rails_app/app/controllers/users_controller.rb +0 -26
  142. data/spec/rails_app/app/helpers/application_helper.rb +0 -2
  143. data/spec/rails_app/app/helpers/devise_helper.rb +0 -2
  144. data/spec/rails_app/app/javascript/App.vue +0 -40
  145. data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +0 -82
  146. data/spec/rails_app/app/javascript/components/Top.vue +0 -98
  147. data/spec/rails_app/app/javascript/components/notifications/Index.vue +0 -200
  148. data/spec/rails_app/app/javascript/components/notifications/Notification.vue +0 -133
  149. data/spec/rails_app/app/javascript/components/notifications/NotificationContent.vue +0 -122
  150. data/spec/rails_app/app/javascript/components/subscriptions/Index.vue +0 -279
  151. data/spec/rails_app/app/javascript/components/subscriptions/NewSubscription.vue +0 -112
  152. data/spec/rails_app/app/javascript/components/subscriptions/NotificationKey.vue +0 -141
  153. data/spec/rails_app/app/javascript/components/subscriptions/Subscription.vue +0 -226
  154. data/spec/rails_app/app/javascript/config/development.js +0 -5
  155. data/spec/rails_app/app/javascript/config/environment.js +0 -7
  156. data/spec/rails_app/app/javascript/config/production.js +0 -5
  157. data/spec/rails_app/app/javascript/config/test.js +0 -5
  158. data/spec/rails_app/app/javascript/packs/application.js +0 -18
  159. data/spec/rails_app/app/javascript/packs/spa.js +0 -14
  160. data/spec/rails_app/app/javascript/router/index.js +0 -73
  161. data/spec/rails_app/app/javascript/store/index.js +0 -37
  162. data/spec/rails_app/app/mailers/.keep +0 -0
  163. data/spec/rails_app/app/mailers/custom_notification_mailer.rb +0 -5
  164. data/spec/rails_app/app/models/admin.rb +0 -35
  165. data/spec/rails_app/app/models/article.rb +0 -54
  166. data/spec/rails_app/app/models/comment.rb +0 -81
  167. data/spec/rails_app/app/models/dummy/dummy_base.rb +0 -11
  168. data/spec/rails_app/app/models/dummy/dummy_group.rb +0 -23
  169. data/spec/rails_app/app/models/dummy/dummy_notifiable.rb +0 -15
  170. data/spec/rails_app/app/models/dummy/dummy_notifiable_target.rb +0 -27
  171. data/spec/rails_app/app/models/dummy/dummy_notifier.rb +0 -15
  172. data/spec/rails_app/app/models/dummy/dummy_subscriber.rb +0 -14
  173. data/spec/rails_app/app/models/dummy/dummy_target.rb +0 -16
  174. data/spec/rails_app/app/models/user.rb +0 -73
  175. data/spec/rails_app/app/views/activity_notification/mailer/dummy_subscribers/test_key.text.erb +0 -1
  176. data/spec/rails_app/app/views/activity_notification/notifications/default/article/_update.html.erb +0 -146
  177. data/spec/rails_app/app/views/activity_notification/notifications/default/custom/_path_test.html.erb +0 -1
  178. data/spec/rails_app/app/views/activity_notification/notifications/default/custom/_test.html.erb +0 -1
  179. data/spec/rails_app/app/views/activity_notification/notifications/users/_custom_index.html.erb +0 -1
  180. data/spec/rails_app/app/views/activity_notification/notifications/users/custom/_test.html.erb +0 -1
  181. data/spec/rails_app/app/views/activity_notification/notifications/users/overridden/custom/_test.html.erb +0 -1
  182. data/spec/rails_app/app/views/activity_notification/optional_targets/admins/amazon_sns/comment/_default.text.erb +0 -10
  183. data/spec/rails_app/app/views/articles/_form.html.erb +0 -24
  184. data/spec/rails_app/app/views/articles/edit.html.erb +0 -8
  185. data/spec/rails_app/app/views/articles/index.html.erb +0 -113
  186. data/spec/rails_app/app/views/articles/new.html.erb +0 -7
  187. data/spec/rails_app/app/views/articles/show.html.erb +0 -49
  188. data/spec/rails_app/app/views/layouts/_header.html.erb +0 -46
  189. data/spec/rails_app/app/views/layouts/application.html.erb +0 -15
  190. data/spec/rails_app/app/views/spa/index.html.erb +0 -2
  191. data/spec/rails_app/babel.config.js +0 -72
  192. data/spec/rails_app/bin/bundle +0 -3
  193. data/spec/rails_app/bin/rails +0 -4
  194. data/spec/rails_app/bin/rake +0 -4
  195. data/spec/rails_app/bin/setup +0 -29
  196. data/spec/rails_app/bin/webpack +0 -18
  197. data/spec/rails_app/bin/webpack-dev-server +0 -18
  198. data/spec/rails_app/config/application.rb +0 -54
  199. data/spec/rails_app/config/boot.rb +0 -5
  200. data/spec/rails_app/config/cable.yml +0 -8
  201. data/spec/rails_app/config/database.yml +0 -36
  202. data/spec/rails_app/config/dynamoid.rb +0 -13
  203. data/spec/rails_app/config/environment.rb +0 -26
  204. data/spec/rails_app/config/environments/development.rb +0 -60
  205. data/spec/rails_app/config/environments/production.rb +0 -85
  206. data/spec/rails_app/config/environments/test.rb +0 -53
  207. data/spec/rails_app/config/initializers/activity_notification.rb +0 -104
  208. data/spec/rails_app/config/initializers/assets.rb +0 -11
  209. data/spec/rails_app/config/initializers/backtrace_silencers.rb +0 -7
  210. data/spec/rails_app/config/initializers/cookies_serializer.rb +0 -3
  211. data/spec/rails_app/config/initializers/copy_it.aws.rb.template +0 -6
  212. data/spec/rails_app/config/initializers/devise.rb +0 -278
  213. data/spec/rails_app/config/initializers/devise_token_auth.rb +0 -55
  214. data/spec/rails_app/config/initializers/filter_parameter_logging.rb +0 -4
  215. data/spec/rails_app/config/initializers/inflections.rb +0 -16
  216. data/spec/rails_app/config/initializers/mime_types.rb +0 -4
  217. data/spec/rails_app/config/initializers/mysql.rb +0 -9
  218. data/spec/rails_app/config/initializers/session_store.rb +0 -3
  219. data/spec/rails_app/config/initializers/wrap_parameters.rb +0 -14
  220. data/spec/rails_app/config/initializers/zeitwerk.rb +0 -10
  221. data/spec/rails_app/config/locales/activity_notification.en.yml +0 -26
  222. data/spec/rails_app/config/locales/devise.en.yml +0 -62
  223. data/spec/rails_app/config/mongoid.yml +0 -13
  224. data/spec/rails_app/config/routes.rb +0 -50
  225. data/spec/rails_app/config/secrets.yml +0 -22
  226. data/spec/rails_app/config/webpack/development.js +0 -5
  227. data/spec/rails_app/config/webpack/environment.js +0 -7
  228. data/spec/rails_app/config/webpack/loaders/vue.js +0 -6
  229. data/spec/rails_app/config/webpack/production.js +0 -5
  230. data/spec/rails_app/config/webpack/test.js +0 -5
  231. data/spec/rails_app/config/webpacker.yml +0 -97
  232. data/spec/rails_app/config.ru +0 -4
  233. data/spec/rails_app/db/migrate/20160716000000_create_test_tables.rb +0 -42
  234. data/spec/rails_app/db/migrate/20181209000000_create_activity_notification_tables.rb +0 -33
  235. data/spec/rails_app/db/migrate/20191201000000_add_tokens_to_users.rb +0 -10
  236. data/spec/rails_app/db/schema.rb +0 -98
  237. data/spec/rails_app/db/seeds.rb +0 -95
  238. data/spec/rails_app/lib/custom_optional_targets/console_output.rb +0 -16
  239. data/spec/rails_app/lib/custom_optional_targets/raise_error.rb +0 -14
  240. data/spec/rails_app/lib/custom_optional_targets/wrong_target.rb +0 -13
  241. data/spec/rails_app/lib/mailer_previews/mailer_preview.rb +0 -29
  242. data/spec/rails_app/package.json +0 -23
  243. data/spec/rails_app/postcss.config.js +0 -12
  244. data/spec/rails_app/public/404.html +0 -67
  245. data/spec/rails_app/public/422.html +0 -67
  246. data/spec/rails_app/public/500.html +0 -66
  247. data/spec/rails_app/public/favicon.ico +0 -0
  248. data/spec/roles/acts_as_group_spec.rb +0 -30
  249. data/spec/roles/acts_as_notifiable_spec.rb +0 -432
  250. data/spec/roles/acts_as_notifier_spec.rb +0 -30
  251. data/spec/roles/acts_as_target_spec.rb +0 -36
  252. data/spec/spec_helper.rb +0 -56
  253. data/spec/version_spec.rb +0 -31
@@ -1,226 +0,0 @@
1
- <template>
2
- <div class="fields_wrapper configured">
3
- <div class="fields_title_wrapper">
4
- <h3 class="fields_title">
5
- {{ subscription.key }}
6
- </h3>
7
-
8
- <p>
9
- <router-link v-bind:to="{ path : $route.path.replace('subscriptions', 'notifications') + '?filtered_by_key=' + subscription.key }">Notifications</router-link>
10
- </p>
11
- </div>
12
-
13
- <div class="field_wrapper subscribing">
14
- <div class="field_label">
15
- <label>
16
- Notification
17
- </label>
18
- </div>
19
- <div class="field">
20
- <div class="ui checkbox">
21
- <div v-if="subscription.subscribing">
22
- <a href="#" v-on:click="unsubscribe(subscription)" data-remote="true">
23
- <input type="checkbox" checked="checked" />
24
- <div class="slider" />
25
- </a>
26
- </div>
27
- <div v-else>
28
- <a href="#" v-on:click="subscribe(subscription)" data-remote="true">
29
- <input type="checkbox" />
30
- <div class="slider" />
31
- </a>
32
- </div>
33
- </div>
34
- </div>
35
- </div>
36
-
37
- <div v-bind:class="[subscription.subscribing ? '' : 'hidden', 'field_wrapper subscribing_to_email']">
38
- <div class="field_label">
39
- <label>
40
- Email notification
41
- </label>
42
- </div>
43
- <div class="field">
44
- <div class="ui checkbox">
45
- <div v-if="subscription.subscribing_to_email">
46
- <a href="#" v-on:click="unsubscribe_to_email(subscription)" data-remote="true">
47
- <label>
48
- <input type="checkbox" checked="checked" />
49
- <div class="slider" />
50
- </label>
51
- </a>
52
- </div>
53
- <div v-else>
54
- <a href="#" v-on:click="subscribe_to_email(subscription)" data-remote="true">
55
- <label>
56
- <input type="checkbox" />
57
- <div class="slider" />
58
- </label>
59
- </a>
60
- </div>
61
- </div>
62
- </div>
63
- </div>
64
-
65
- <div v-bind:class="[subscription.subscribing ? '' : 'hidden', 'field_wrapper subscribing_to_optional_targets']">
66
- <div v-for="(optionalTargetSubscription, optionalTargetName) in subscription.optional_targets" :key="optionalTargetName">
67
- <div class="field_label">
68
- <label>
69
- Optional tagret ({{ optionalTargetName }})
70
- </label>
71
- </div>
72
- <div class="field">
73
- <div class="ui checkbox">
74
- <div v-if="optionalTargetSubscription.subscribing">
75
- <a href="#" v-on:click="unsubscribe_to_optional_target(subscription, optionalTargetName)" data-remote="true">
76
- <label>
77
- <input type="checkbox" checked="checked" />
78
- <div class="slider" />
79
- </label>
80
- </a>
81
- </div>
82
- <div v-else>
83
- <a href="#" v-on:click="subscribe_to_optional_target(subscription, optionalTargetName)" data-remote="true">
84
- <label>
85
- <input type="checkbox" />
86
- <div class="slider" />
87
- </label>
88
- </a>
89
- </div>
90
- </div>
91
- </div>
92
- </div>
93
- </div>
94
-
95
- <div class="ui button">
96
- <a href="#" v-on:click="destroy(subscription)" data-confirm="Are you sure?" class="button" data-remote="true">Destroy</a>
97
- </div>
98
- </div>
99
- </template>
100
-
101
- <script>
102
- import axios from 'axios'
103
-
104
- export default {
105
- name: 'Subscription',
106
- props: {
107
- targetSubscription: {
108
- type: Object,
109
- required: true
110
- },
111
- targetApiPath: {
112
- type: String,
113
- required: true
114
- }
115
- },
116
- data () {
117
- return {
118
- subscription: this.targetSubscription,
119
- baseURL: axios.defaults.baseURL + this.targetApiPath
120
- }
121
- },
122
- methods: {
123
- subscribe (subscription) {
124
- axios
125
- .put(this.targetApiPath + '/subscriptions/' + subscription.id + '/subscribe')
126
- .then(response => {
127
- if (response.status == 200) {
128
- this.subscription = response.data
129
- }
130
- })
131
- .catch (error => {
132
- if (error.response.status == 401) {
133
- this.$router.push('/logout');
134
- }
135
- })
136
- },
137
- unsubscribe (subscription) {
138
- axios
139
- .put(this.targetApiPath + '/subscriptions/' + subscription.id + '/unsubscribe')
140
- .then(response => {
141
- if (response.status == 200) {
142
- this.subscription = response.data
143
- }
144
- })
145
- .catch (error => {
146
- if (error.response.status == 401) {
147
- this.$router.push('/logout');
148
- }
149
- })
150
- },
151
- subscribe_to_email (subscription) {
152
- axios
153
- .put(this.targetApiPath + '/subscriptions/' + subscription.id + '/subscribe_to_email')
154
- .then(response => {
155
- if (response.status == 200) {
156
- this.subscription = response.data
157
- }
158
- })
159
- .catch (error => {
160
- if (error.response.status == 401) {
161
- this.$router.push('/logout');
162
- }
163
- })
164
- },
165
- unsubscribe_to_email (subscription) {
166
- axios
167
- .put(this.targetApiPath + '/subscriptions/' + subscription.id + '/unsubscribe_to_email')
168
- .then(response => {
169
- if (response.status == 200) {
170
- this.subscription = response.data
171
- }
172
- })
173
- .catch (error => {
174
- if (error.response.status == 401) {
175
- this.$router.push('/logout');
176
- }
177
- })
178
- },
179
- subscribe_to_optional_target (subscription, optionalTargetName) {
180
- axios
181
- .put(this.targetApiPath + '/subscriptions/' + subscription.id + '/subscribe_to_optional_target?optional_target_name=' + optionalTargetName)
182
- .then(response => {
183
- if (response.status == 200) {
184
- this.subscription = response.data
185
- }
186
- })
187
- .catch (error => {
188
- if (error.response.status == 401) {
189
- this.$router.push('/logout');
190
- }
191
- })
192
- },
193
- unsubscribe_to_optional_target (subscription, optionalTargetName) {
194
- axios
195
- .put(this.targetApiPath + '/subscriptions/' + subscription.id + '/unsubscribe_to_optional_target?optional_target_name=' + optionalTargetName)
196
- .then(response => {
197
- if (response.status == 200) {
198
- this.subscription = response.data
199
- }
200
- })
201
- .catch (error => {
202
- if (error.response.status == 401) {
203
- this.$router.push('/logout');
204
- }
205
- })
206
- },
207
- destroy (subscription) {
208
- axios
209
- .delete(this.targetApiPath + '/subscriptions/' + subscription.id)
210
- .then(response => {
211
- if (response.status == 204) {
212
- this.$emit('getSubscriptions');
213
- }
214
- })
215
- .catch (error => {
216
- if (error.response.status == 401) {
217
- this.$router.push('/logout');
218
- }
219
- })
220
- }
221
- }
222
- }
223
- </script>
224
-
225
- <style scoped>
226
- </style>
@@ -1,5 +0,0 @@
1
- const config = {
2
- ACTION_CABLE_CONNECTION_URL: 'ws://localhost:3000/cable'
3
- }
4
-
5
- module.exports = config;
@@ -1,7 +0,0 @@
1
- const config = require('./' + process.env.NODE_ENV);
2
-
3
- export default class Environment {
4
- static get ACTION_CABLE_CONNECTION_URL() {
5
- return config.ACTION_CABLE_CONNECTION_URL;
6
- }
7
- }
@@ -1,5 +0,0 @@
1
- const config = {
2
- ACTION_CABLE_CONNECTION_URL: 'wss://activity-notification-example.herokuapp.com/cable'
3
- }
4
-
5
- module.exports = config;
@@ -1,5 +0,0 @@
1
- const config = {
2
- ACTION_CABLE_CONNECTION_URL: 'ws://localhost:3000/cable'
3
- }
4
-
5
- module.exports = config;
@@ -1,18 +0,0 @@
1
- /* eslint no-console:0 */
2
- // This file is automatically compiled by Webpack, along with any other files
3
- // present in this directory. You're encouraged to place your actual application logic in
4
- // a relevant structure within app/javascript and only use these pack files to reference
5
- // that code so it'll be compiled.
6
- //
7
- // To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
8
- // layout file, like app/views/layouts/application.html.erb
9
-
10
-
11
- // Uncomment to copy all static images under ../images to the output folder and reference
12
- // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
13
- // or the `imagePath` JavaScript helper below.
14
- //
15
- // const images = require.context('../images', true)
16
- // const imagePath = (name) => images(name, true)
17
-
18
- console.log('Hello World from Webpacker')
@@ -1,14 +0,0 @@
1
- import Vue from 'vue'
2
- import App from '../App.vue'
3
- import router from '../router'
4
- import store from '../store'
5
-
6
- Vue.config.productionTip = false
7
-
8
- document.addEventListener('DOMContentLoaded', () => {
9
- new Vue({
10
- router,
11
- store,
12
- render: h => h(App)
13
- }).$mount('#spa')
14
- })
@@ -1,73 +0,0 @@
1
- import Vue from 'vue'
2
- import VueRouter from 'vue-router'
3
- import store from '../store'
4
- import DeviseTokenAuth from '../components/DeviseTokenAuth.vue'
5
- import Top from '../components/Top.vue'
6
- import NotificationsIndex from '../components/notifications/Index.vue'
7
- import SubscriptionsIndex from '../components/subscriptions/Index.vue'
8
-
9
- Vue.use(VueRouter)
10
-
11
- const routes = [
12
- // Routes for common components
13
- { path: '/', component: Top },
14
- { path: '/login', component: DeviseTokenAuth },
15
- { path: '/logout', component: DeviseTokenAuth, props: { isLogout: true } },
16
- // Routes for single page application working with activity_notification REST API backend for users
17
- {
18
- path: '/notifications',
19
- name: 'AuthenticatedUserNotificationsIndex',
20
- component: NotificationsIndex,
21
- props: () => ({ target_type: 'users', target: store.getters.currentUser }),
22
- meta: { requiresAuth: true }
23
- },
24
- {
25
- path: '/subscriptions',
26
- name: 'AuthenticatedUserSubscriptionsIndex',
27
- component: SubscriptionsIndex,
28
- props: () => ({ target_type: 'users', target: store.getters.currentUser }),
29
- meta: { requiresAuth: true }
30
- },
31
- // Routes for single page application working with activity_notification REST API backend for admins
32
- {
33
- path: '/admins/notifications',
34
- name: 'AuthenticatedAdminNotificationsIndex',
35
- component: NotificationsIndex,
36
- props: () => ({ target_type: 'admins', targetApiPath: 'admins', target: store.getters.currentUser.admin }),
37
- meta: { requiresAuth: true }
38
- },
39
- {
40
- path: '/admins/subscriptions',
41
- name: 'AuthenticatedAdminSubscriptionsIndex',
42
- component: SubscriptionsIndex,
43
- props: () => ({ target_type: 'admins', targetApiPath: 'admins', target: store.getters.currentUser.admin }),
44
- meta: { requiresAuth: true }
45
- },
46
- // Routes for single page application working with activity_notification REST API backend for unauthenticated targets
47
- {
48
- path: '/:target_type/:target_id/notifications',
49
- name: 'UnauthenticatedTargetNotificationsIndex',
50
- component: NotificationsIndex,
51
- props : true
52
- },
53
- {
54
- path: '/:target_type/:target_id/subscriptions',
55
- name: 'UnauthenticatedTargetSubscriptionsIndex',
56
- component: SubscriptionsIndex,
57
- props : true
58
- }
59
- ]
60
-
61
- const router = new VueRouter({
62
- routes
63
- })
64
-
65
- router.beforeEach((to, from, next) => {
66
- if (to.matched.some(record => record.meta.requiresAuth) && !store.getters.userSignedIn) {
67
- next({ path: '/login', query: { redirect: to.fullPath }});
68
- } else {
69
- next();
70
- }
71
- })
72
-
73
- export default router
@@ -1,37 +0,0 @@
1
- import Vue from 'vue'
2
- import Vuex from 'vuex'
3
- import createPersistedState from "vuex-persistedstate"
4
-
5
- Vue.use(Vuex)
6
-
7
- export default new Vuex.Store({
8
- state: {
9
- signedInStatus: false,
10
- currentUser: null,
11
- authHeaders: {}
12
- },
13
- mutations: {
14
- signIn(state, { user, authHeaders }) {
15
- state.currentUser = user;
16
- state.authHeaders = authHeaders;
17
- state.signedInStatus = true;
18
- },
19
- signOut(state) {
20
- state.signedInStatus = false;
21
- state.currentUser = null;
22
- state.authHeaders = {};
23
- }
24
- },
25
- getters: {
26
- userSignedIn(state) {
27
- return state.signedInStatus;
28
- },
29
- currentUser(state) {
30
- return state.currentUser;
31
- },
32
- authHeaders(state) {
33
- return state.authHeaders;
34
- }
35
- },
36
- plugins: [createPersistedState({storage: window.sessionStorage})]
37
- });
File without changes
@@ -1,5 +0,0 @@
1
- class CustomNotificationMailer < ActivityNotification::Mailer
2
- def send_notification_email(notification, options = {})
3
- 'This is CustomNotificationMailer'
4
- end
5
- end
@@ -1,35 +0,0 @@
1
- module AdminModel
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- belongs_to :user
6
- validates :user, presence: true
7
-
8
- acts_as_notification_target email_allowed: false,
9
- subscription_allowed: true,
10
- action_cable_allowed: true, action_cable_with_devise: true,
11
- devise_resource: :user,
12
- current_devise_target: ->(current_user) { current_user.admin },
13
- printable_name: ->(admin) { "#{admin.user.name} (admin)" }
14
- end
15
- end
16
-
17
- unless ENV['AN_TEST_DB'] == 'mongodb'
18
- class Admin < ActiveRecord::Base
19
- include AdminModel
20
- default_scope { order(:id) }
21
- end
22
- else
23
- require 'mongoid'
24
- class Admin
25
- include Mongoid::Document
26
- include Mongoid::Timestamps
27
- include GlobalID::Identification
28
-
29
- field :phone_number, type: String
30
- field :slack_username, type: String
31
-
32
- include ActivityNotification::Models
33
- include AdminModel
34
- end
35
- end
@@ -1,54 +0,0 @@
1
- module ArticleModel
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- belongs_to :user
6
- has_many :comments, dependent: :destroy
7
- validates :user, presence: true
8
-
9
- acts_as_notifiable :users,
10
- targets: ->(article) { User.all.to_a - [article.user] },
11
- notifier: :user, email_allowed: true,
12
- action_cable_allowed: true, action_cable_api_allowed: true,
13
- printable_name: ->(article) { "new article \"#{article.title}\"" },
14
- dependent_notifications: :delete_all
15
-
16
- acts_as_notifiable :admins,
17
- targets: ->(article) { Admin.all.to_a },
18
- notifier: :user,
19
- action_cable_allowed: true, action_cable_api_allowed: true,
20
- tracked: Rails.env.test? ? {only: []} : { only: [:create, :update], action_cable_rendering: { fallback: :default } },
21
- printable_name: ->(article) { "new article \"#{article.title}\"" },
22
- dependent_notifications: :delete_all
23
-
24
- acts_as_notification_group printable_name: ->(article) { "article \"#{article.title}\"" }
25
- end
26
-
27
- def author?(user)
28
- self.user == user
29
- end
30
- end
31
-
32
- unless ENV['AN_TEST_DB'] == 'mongodb'
33
- class Article < ActiveRecord::Base
34
- include ArticleModel
35
- has_many :commented_users, through: :comments, source: :user
36
- end
37
- else
38
- require 'mongoid'
39
- class Article
40
- include Mongoid::Document
41
- include Mongoid::Timestamps
42
- include GlobalID::Identification
43
-
44
- field :title, type: String
45
- field :body, type: String
46
-
47
- include ActivityNotification::Models
48
- include ArticleModel
49
-
50
- def commented_users
51
- User.where(:id.in => comments.pluck(:user_id))
52
- end
53
- end
54
- end
@@ -1,81 +0,0 @@
1
- module CommentModel
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- belongs_to :article
6
- belongs_to :user
7
- validates :article, presence: true
8
- validates :user, presence: true
9
-
10
- acts_as_notifiable :users,
11
- targets: ->(comment, key) { ([comment.article.user] + comment.article.reload.commented_users.to_a - [comment.user]).uniq },
12
- group: :article, notifier: :user, email_allowed: true,
13
- action_cable_allowed: true, action_cable_api_allowed: true,
14
- parameters: { 'test_default_param' => '1' },
15
- notifiable_path: :article_notifiable_path,
16
- printable_name: ->(comment) { "comment \"#{comment.body}\"" },
17
- dependent_notifications: :update_group_and_delete_all
18
-
19
- require 'custom_optional_targets/console_output'
20
- optional_targets = {}
21
- # optional_targets = optional_targets.merge(CustomOptionalTarget::ConsoleOutput => {})
22
- if ENV['OPTIONAL_TARGET_AMAZON_SNS']
23
- require 'activity_notification/optional_targets/amazon_sns'
24
- if ENV['OPTIONAL_TARGET_AMAZON_SNS_TOPIC_ARN']
25
- optional_targets = optional_targets.merge(
26
- ActivityNotification::OptionalTarget::AmazonSNS => { topic_arn: ENV['OPTIONAL_TARGET_AMAZON_SNS_TOPIC_ARN'] }
27
- )
28
- elsif ENV['OPTIONAL_TARGET_AMAZON_SNS_PHONE_NUMBER']
29
- optional_targets = optional_targets.merge(
30
- ActivityNotification::OptionalTarget::AmazonSNS => { phone_number: :phone_number }
31
- )
32
- end
33
- end
34
- if ENV['OPTIONAL_TARGET_SLACK']
35
- require 'activity_notification/optional_targets/slack'
36
- optional_targets = optional_targets.merge(
37
- ActivityNotification::OptionalTarget::Slack => {
38
- webhook_url: ENV['OPTIONAL_TARGET_SLACK_WEBHOOK_URL'], target_username: :slack_username,
39
- channel: ENV['OPTIONAL_TARGET_SLACK_CHANNEL'] || 'activity_notification',
40
- username: 'ActivityNotification', icon_emoji: ":ghost:"
41
- }
42
- )
43
- end
44
- acts_as_notifiable :admins,
45
- targets: ->(comment) { Admin.all.to_a },
46
- group: :article, notifier: :user, notifiable_path: :article_notifiable_path,
47
- action_cable_allowed: true, action_cable_api_allowed: true,
48
- tracked: Rails.env.test? ? {only: []} : { only: [:create], action_cable_rendering: { fallback: :default } },
49
- printable_name: ->(comment) { "comment \"#{comment.body}\"" },
50
- dependent_notifications: :delete_all,
51
- optional_targets: optional_targets
52
-
53
- acts_as_group
54
- end
55
-
56
- def article_notifiable_path
57
- article_path(article)
58
- end
59
-
60
- def author?(user)
61
- self.user == user
62
- end
63
- end
64
-
65
- unless ENV['AN_TEST_DB'] == 'mongodb'
66
- class Comment < ActiveRecord::Base
67
- include CommentModel
68
- end
69
- else
70
- require 'mongoid'
71
- class Comment
72
- include Mongoid::Document
73
- include Mongoid::Timestamps
74
- include GlobalID::Identification
75
-
76
- field :body, type: String
77
-
78
- include ActivityNotification::Models
79
- include CommentModel
80
- end
81
- end
@@ -1,11 +0,0 @@
1
- unless ENV['AN_TEST_DB'] == 'mongodb'
2
- class Dummy::DummyBase < ActiveRecord::Base
3
- end
4
- else
5
- class Dummy::DummyBase
6
- include Mongoid::Document
7
- include Mongoid::Timestamps
8
- include GlobalID::Identification
9
- include ActivityNotification::Models
10
- end
11
- end
@@ -1,23 +0,0 @@
1
- unless ENV['AN_TEST_DB'] == 'mongodb'
2
- class Dummy::DummyGroup < ActiveRecord::Base
3
- self.table_name = :articles
4
- include ActivityNotification::Group
5
- end
6
-
7
- def printable_target_name
8
- "dummy"
9
- end
10
-
11
- def printable_group_name
12
- "dummy"
13
- end
14
- else
15
- class Dummy::DummyGroup
16
- include Mongoid::Document
17
- include Mongoid::Timestamps
18
- include GlobalID::Identification
19
- include ActivityNotification::Models
20
- include ActivityNotification::Group
21
- field :title, type: String
22
- end
23
- end
@@ -1,15 +0,0 @@
1
- unless ENV['AN_TEST_DB'] == 'mongodb'
2
- class Dummy::DummyNotifiable < ActiveRecord::Base
3
- self.table_name = :articles
4
- include ActivityNotification::Notifiable
5
- end
6
- else
7
- class Dummy::DummyNotifiable
8
- include Mongoid::Document
9
- include Mongoid::Timestamps
10
- include GlobalID::Identification
11
- include ActivityNotification::Models
12
- include ActivityNotification::Notifiable
13
- field :title, type: String
14
- end
15
- end
@@ -1,27 +0,0 @@
1
- unless ENV['AN_TEST_DB'] == 'mongodb'
2
- class Dummy::DummyNotifiableTarget < ActiveRecord::Base
3
- self.table_name = :users
4
- acts_as_target
5
- acts_as_notifiable :dummy_notifiable_targets, targets: -> (n, key) { Dummy::DummyNotifiableTarget.all }, tracked: true
6
-
7
- def notifiable_path(target_type, key = nil)
8
- "dummy_path"
9
- end
10
- end
11
- else
12
- class Dummy::DummyNotifiableTarget
13
- include Mongoid::Document
14
- include Mongoid::Timestamps
15
- include GlobalID::Identification
16
- field :email, type: String, default: ""
17
- field :name, type: String
18
-
19
- include ActivityNotification::Models
20
- acts_as_target
21
- acts_as_notifiable :dummy_notifiable_targets, targets: -> (n, key) { Dummy::DummyNotifiableTarget.all }, tracked: true
22
-
23
- def notifiable_path(target_type, key = nil)
24
- "dummy_path"
25
- end
26
- end
27
- end
@@ -1,15 +0,0 @@
1
- unless ENV['AN_TEST_DB'] == 'mongodb'
2
- class Dummy::DummyNotifier < ActiveRecord::Base
3
- self.table_name = :users
4
- include ActivityNotification::Notifier
5
- end
6
- else
7
- class Dummy::DummyNotifier
8
- include Mongoid::Document
9
- include Mongoid::Timestamps
10
- include GlobalID::Identification
11
- include ActivityNotification::Models
12
- include ActivityNotification::Notifier
13
- field :name, type: String
14
- end
15
- end