activity_notification 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +16 -11
- data/README.md +16 -16
- data/activity_notification.gemspec +2 -2
- data/app/views/activity_notification/optional_targets/default/slack/_default.text.erb +1 -1
- data/gemfiles/Gemfile.rails-4.2.lock +15 -15
- data/gemfiles/Gemfile.rails-5.0.lock +14 -14
- data/lib/activity_notification/optional_targets/slack.rb +13 -13
- data/lib/activity_notification/version.rb +1 -1
- data/spec/rails_app/app/models/comment.rb +24 -11
- data/spec/rails_app/app/views/activity_notification/optional_targets/admins/amazon_sns/comment/_default.text.erb +3 -1
- data/spec/rails_app/db/migrate/20160715050433_create_test_tables.rb +1 -1
- data/spec/rails_app/db/schema.rb +1 -1
- data/spec/rails_app/db/seeds.rb +6 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 10573a031431162243ea0c47762d6a23f2a1c5fc
|
|
4
|
+
data.tar.gz: 9d79ff21207045e1f8adb3c6154749b25f4cfbfc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 099d83aa693ea68f03ea346bc8d58f9ad03f812dd28b78ddd11e4ca31c18424949a3e1abe36ef5da77b1d8c39097211b5ca58dd852855bff831809801c179af7
|
|
7
|
+
data.tar.gz: c388ceeae7685591b3e8585efcf6ec597e5a7a343b48f42b4ad1d9bf960c3a31a17397e7071b9b95855df42cb653ee174642313edcff914a28444d22a3dfdc18
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 1.2.1 / 2017-01-06
|
|
2
|
+
[Full Changelog](http://github.com/simukappu/activity_notification/compare/v1.2.0...v1.2.1)
|
|
3
|
+
|
|
4
|
+
Enhancements:
|
|
5
|
+
* Support default Slack optional target with slack-notifier 2.0.0
|
|
6
|
+
|
|
7
|
+
Breaking Changes:
|
|
8
|
+
|
|
9
|
+
* Rename :slack_name initializing parameter and template parameter of default Slack optional target to :target_username
|
|
10
|
+
|
|
1
11
|
## 1.2.0 / 2017-01-06
|
|
2
12
|
[Full Changelog](http://github.com/simukappu/activity_notification/compare/v1.1.0...v1.2.0)
|
|
3
13
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
activity_notification (1.2.
|
|
4
|
+
activity_notification (1.2.1)
|
|
5
5
|
activerecord (>= 4.2.0)
|
|
6
6
|
i18n (>= 0.5.0)
|
|
7
7
|
jquery-rails (>= 3.1.1)
|
|
@@ -52,13 +52,13 @@ GEM
|
|
|
52
52
|
railties (>= 3.0)
|
|
53
53
|
rspec-rails (>= 2.2)
|
|
54
54
|
arel (7.1.4)
|
|
55
|
-
aws-sdk (2.6.
|
|
56
|
-
aws-sdk-resources (= 2.6.
|
|
57
|
-
aws-sdk-core (2.6.
|
|
55
|
+
aws-sdk (2.6.44)
|
|
56
|
+
aws-sdk-resources (= 2.6.44)
|
|
57
|
+
aws-sdk-core (2.6.44)
|
|
58
58
|
aws-sigv4 (~> 1.0)
|
|
59
59
|
jmespath (~> 1.0)
|
|
60
|
-
aws-sdk-resources (2.6.
|
|
61
|
-
aws-sdk-core (= 2.6.
|
|
60
|
+
aws-sdk-resources (2.6.44)
|
|
61
|
+
aws-sdk-core (= 2.6.44)
|
|
62
62
|
aws-sigv4 (1.0.0)
|
|
63
63
|
bcrypt (3.1.11)
|
|
64
64
|
builder (3.2.2)
|
|
@@ -80,6 +80,10 @@ GEM
|
|
|
80
80
|
warden (~> 1.2.3)
|
|
81
81
|
diff-lcs (1.2.5)
|
|
82
82
|
docile (1.1.5)
|
|
83
|
+
dotenv (2.1.1)
|
|
84
|
+
dotenv-rails (2.1.1)
|
|
85
|
+
dotenv (= 2.1.1)
|
|
86
|
+
railties (>= 4.0, < 5.1)
|
|
83
87
|
erubis (2.7.0)
|
|
84
88
|
factory_girl (4.8.0)
|
|
85
89
|
activesupport (>= 3.0.0)
|
|
@@ -106,7 +110,7 @@ GEM
|
|
|
106
110
|
mini_portile2 (2.1.0)
|
|
107
111
|
minitest (5.10.1)
|
|
108
112
|
nio4r (1.2.1)
|
|
109
|
-
nokogiri (1.7.0)
|
|
113
|
+
nokogiri (1.7.0.1)
|
|
110
114
|
mini_portile2 (~> 2.1.0)
|
|
111
115
|
orm_adapter (0.5.0)
|
|
112
116
|
rack (2.0.1)
|
|
@@ -164,7 +168,7 @@ GEM
|
|
|
164
168
|
json (>= 1.8, < 3)
|
|
165
169
|
simplecov-html (~> 0.10.0)
|
|
166
170
|
simplecov-html (0.10.0)
|
|
167
|
-
slack-notifier (
|
|
171
|
+
slack-notifier (2.0.0)
|
|
168
172
|
sprockets (3.7.1)
|
|
169
173
|
concurrent-ruby (~> 1.0)
|
|
170
174
|
rack (> 1, < 3)
|
|
@@ -172,7 +176,7 @@ GEM
|
|
|
172
176
|
actionpack (>= 4.0)
|
|
173
177
|
activesupport (>= 4.0)
|
|
174
178
|
sprockets (>= 3.0.0)
|
|
175
|
-
sqlite3 (1.3.
|
|
179
|
+
sqlite3 (1.3.13)
|
|
176
180
|
term-ansicolor (1.4.0)
|
|
177
181
|
tins (~> 1.0)
|
|
178
182
|
thor (0.19.4)
|
|
@@ -201,13 +205,14 @@ DEPENDENCIES
|
|
|
201
205
|
bullet
|
|
202
206
|
coveralls
|
|
203
207
|
devise (~> 4.2.0)
|
|
208
|
+
dotenv-rails
|
|
204
209
|
factory_girl_rails (~> 4.8.0)
|
|
205
210
|
rails (~> 5.0.0)
|
|
206
211
|
rails-controller-testing
|
|
207
212
|
rspec-rails (~> 3.5.1)
|
|
208
213
|
simplecov (~> 0.12.0)
|
|
209
|
-
slack-notifier (
|
|
210
|
-
sqlite3 (~> 1.3.
|
|
214
|
+
slack-notifier (>= 1.5.1)
|
|
215
|
+
sqlite3 (~> 1.3.13)
|
|
211
216
|
timecop
|
|
212
217
|
yard (~> 0.9.5)
|
|
213
218
|
yard-activesupport-concern (~> 0.0.1)
|
data/README.md
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
<kbd></kbd>
|
|
36
36
|
|
|
37
37
|
### Amazon SNS as optional notification target
|
|
38
|
-
<kbd></kbd>
|
|
39
39
|
|
|
40
40
|
### Slack as optional notification target
|
|
41
41
|
<kbd></kbd>
|
|
@@ -61,22 +61,22 @@
|
|
|
61
61
|
4. [i18n for notifications](#i18n-for-notifications)
|
|
62
62
|
3. [Functions](#functions)
|
|
63
63
|
1. [Email notification](#email-notification)
|
|
64
|
-
1. [
|
|
64
|
+
1. [Mailer setup](#mailer-setup)
|
|
65
65
|
2. [Email templates](#email-templates)
|
|
66
66
|
3. [i18n for email](#i18n-for-email)
|
|
67
67
|
2. [Batch email notification](#batch-email-notification)
|
|
68
|
-
1. [
|
|
68
|
+
1. [Batch mailer setup](#batch-mailer-setup)
|
|
69
69
|
2. [Batch email templates](#batch-email-templates)
|
|
70
70
|
3. [i18n for batch email](#i18n-for-batch-email)
|
|
71
71
|
3. [Grouping notifications](#grouping-notifications)
|
|
72
72
|
4. [Subscription management](#subscription-management)
|
|
73
|
-
1. [
|
|
74
|
-
2. [
|
|
75
|
-
3. [
|
|
73
|
+
1. [Configuring subscriptions](#configuring-subscriptions)
|
|
74
|
+
2. [Managing subscriptions](#managing-subscriptions)
|
|
75
|
+
3. [Customizing subscriptions](#customizing-subscriptions)
|
|
76
76
|
5. [Integration with Devise](#integration-with-devise)
|
|
77
77
|
6. [Optional notification targets](#optional-notification-targets)
|
|
78
|
-
1. [
|
|
79
|
-
2. [Customizing message format](#
|
|
78
|
+
1. [Configuring optional targets](#configuring-optional-targets)
|
|
79
|
+
2. [Customizing message format](#customizing-message-format)
|
|
80
80
|
3. [Amazon SNS as optional target](#amazon-sns-as-optional-target)
|
|
81
81
|
4. [Slack as optional target](#slack-as-optional-target)
|
|
82
82
|
5. [Developing custom optional targets](#developing-custom-optional-targets)
|
|
@@ -414,7 +414,7 @@ This structure is valid for notifications with keys `"notification.comment.reply
|
|
|
414
414
|
|
|
415
415
|
`activity_notification` provides email notification to the notification targets.
|
|
416
416
|
|
|
417
|
-
####
|
|
417
|
+
#### Mailer setup
|
|
418
418
|
|
|
419
419
|
Set up SMTP server configuration for `ActionMailer`. Then, you need to set up the default URL options for the `activity_notification` mailer in each environment. Here is a possible configuration for `config/environments/development.rb`:
|
|
420
420
|
|
|
@@ -481,7 +481,7 @@ notification:
|
|
|
481
481
|
|
|
482
482
|
`activity_notification` provides batch email notification to the notification targets. You can send notification email daily, hourly or weekly and so on with a scheduler like `whenever`.
|
|
483
483
|
|
|
484
|
-
####
|
|
484
|
+
#### Batch mailer setup
|
|
485
485
|
|
|
486
486
|
Set up SMTP server configuration for `ActionMailer` and the default URL options for the `activity_notification` mailer in each environment.
|
|
487
487
|
|
|
@@ -591,7 +591,7 @@ Then, you will see `Kevin and 7 other users posted 10 comments to your article"`
|
|
|
591
591
|
|
|
592
592
|
`activity_notification` provides the function for subscription management of notifications and notification email.
|
|
593
593
|
|
|
594
|
-
####
|
|
594
|
+
#### Configuring subscriptions
|
|
595
595
|
|
|
596
596
|
Subscription management is disabled as default. You can configure to enable subscription management in initializer `activity_notification.rb`.
|
|
597
597
|
|
|
@@ -617,7 +617,7 @@ $ bin/rake db:migrate
|
|
|
617
617
|
```
|
|
618
618
|
|
|
619
619
|
|
|
620
|
-
####
|
|
620
|
+
#### Managing subscriptions
|
|
621
621
|
|
|
622
622
|
Subscriptions are managed by `Subscription` model record which belongs to target and key of the notification.
|
|
623
623
|
`Subscription#subscribing` manages subscription of notifications.
|
|
@@ -662,7 +662,7 @@ user.find_or_create_subscription('comment.reply').unsubscribe
|
|
|
662
662
|
user.find_or_create_subscription('comment.reply').unsubscribe_to_email
|
|
663
663
|
```
|
|
664
664
|
|
|
665
|
-
####
|
|
665
|
+
#### Customizing subscriptions
|
|
666
666
|
|
|
667
667
|
`activity_notification` provides basic controllers and views to manage the subscriptions.
|
|
668
668
|
|
|
@@ -752,7 +752,7 @@ In this example `activity_notification` will confirm the `user` who `admin` belo
|
|
|
752
752
|
|
|
753
753
|
`activity_notification` supports configurable optional notification targets like Amazon SNS, Slack, SMS and so on.
|
|
754
754
|
|
|
755
|
-
####
|
|
755
|
+
#### Configuring optional targets
|
|
756
756
|
|
|
757
757
|
`activity_notification` provides default optional target implementation for Amazon SNS and Slack.
|
|
758
758
|
You can develop any optional target classes which extends `ActivityNotification::OptionalTarget::Base`, and configure them to notifiable model by `acts_as_notifiable` like this.
|
|
@@ -835,7 +835,7 @@ First, add `slack-notifier` gem to your Gemfile and create Incoming WebHooks in
|
|
|
835
835
|
gem 'slack-notifier'
|
|
836
836
|
```
|
|
837
837
|
|
|
838
|
-
Then, write `require 'activity_notification/optional_targets/slack'` statement in your notifiable model and set `ActivityNotification::OptionalTarget::Slack` to `acts_as_notifiable` with `:webhook_url` and `:
|
|
838
|
+
Then, write `require 'activity_notification/optional_targets/slack'` statement in your notifiable model and set `ActivityNotification::OptionalTarget::Slack` to `acts_as_notifiable` with `:webhook_url` and `:target_username` initializing parameters. `:webhook_url` is created WebHook URL and required, `:target_username` is target's slack user name as String value, symbol method name or lambda function and is optional.
|
|
839
839
|
Any other options for `Slack::Notifier.new` are available as initializing parameters. See [Github slack-notifier](https://github.com/stevenosloan/slack-notifier) and [API Reference of Class: Slack::Notifier](http://www.rubydoc.info/gems/slack-notifier/1.5.1/Slack/Notifier) for more details.
|
|
840
840
|
|
|
841
841
|
```ruby
|
|
@@ -845,7 +845,7 @@ class Comment < ActiveRecord::Base
|
|
|
845
845
|
optional_targets: {
|
|
846
846
|
ActivityNotification::OptionalTarget::Slack => {
|
|
847
847
|
webhook_url: 'https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX',
|
|
848
|
-
|
|
848
|
+
target_username: :slack_username, channel: 'activity_notification', username: 'ActivityNotification', icon_emoji: ":ghost:"
|
|
849
849
|
}
|
|
850
850
|
}
|
|
851
851
|
end
|
|
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
|
25
25
|
s.add_dependency 'activerecord', '>= 4.2.0'
|
|
26
26
|
s.add_dependency 'jquery-rails', '>= 3.1.1'
|
|
27
27
|
|
|
28
|
-
s.add_development_dependency 'sqlite3', '~> 1.3.
|
|
28
|
+
s.add_development_dependency 'sqlite3', '~> 1.3.13'
|
|
29
29
|
s.add_development_dependency 'rspec-rails', '~> 3.5.1'
|
|
30
30
|
s.add_development_dependency 'factory_girl_rails', '~> 4.8.0'
|
|
31
31
|
s.add_development_dependency 'simplecov', '~> 0.12.0'
|
|
@@ -33,5 +33,5 @@ Gem::Specification.new do |s|
|
|
|
33
33
|
s.add_development_dependency 'yard-activesupport-concern', '~> 0.0.1'
|
|
34
34
|
s.add_development_dependency 'devise', '~> 4.2.0'
|
|
35
35
|
s.add_development_dependency 'aws-sdk', '~> 2'
|
|
36
|
-
s.add_development_dependency 'slack-notifier', '
|
|
36
|
+
s.add_development_dependency 'slack-notifier', '>= 1.5.1'
|
|
37
37
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<%= @
|
|
1
|
+
<%= @target_username.present? ? "Hi <@#{@target_username}>," : "<!channel>," %>
|
|
2
2
|
|
|
3
3
|
<%= @notification.notifier.present? ? @notification.notifier.printable_notifier_name : 'Someone' %> notified you of <%= @notification.notifiable.printable_notifiable_name(@notification.target) %><%= " in #{@notification.group.printable_group_name}" if @notification.group.present? %>.
|
|
4
4
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ../
|
|
3
3
|
specs:
|
|
4
|
-
activity_notification (1.2.
|
|
4
|
+
activity_notification (1.2.1)
|
|
5
5
|
activerecord (>= 4.2.0)
|
|
6
6
|
i18n (>= 0.5.0)
|
|
7
7
|
jquery-rails (>= 3.1.1)
|
|
@@ -49,18 +49,18 @@ GEM
|
|
|
49
49
|
activesupport (>= 3.0)
|
|
50
50
|
railties (>= 3.0)
|
|
51
51
|
rspec-rails (>= 2.2)
|
|
52
|
-
arel (6.0.
|
|
53
|
-
aws-sdk (2.6.
|
|
54
|
-
aws-sdk-resources (= 2.6.
|
|
55
|
-
aws-sdk-core (2.6.
|
|
52
|
+
arel (6.0.4)
|
|
53
|
+
aws-sdk (2.6.44)
|
|
54
|
+
aws-sdk-resources (= 2.6.44)
|
|
55
|
+
aws-sdk-core (2.6.44)
|
|
56
56
|
aws-sigv4 (~> 1.0)
|
|
57
57
|
jmespath (~> 1.0)
|
|
58
|
-
aws-sdk-resources (2.6.
|
|
59
|
-
aws-sdk-core (= 2.6.
|
|
58
|
+
aws-sdk-resources (2.6.44)
|
|
59
|
+
aws-sdk-core (= 2.6.44)
|
|
60
60
|
aws-sigv4 (1.0.0)
|
|
61
61
|
bcrypt (3.1.11)
|
|
62
62
|
builder (3.2.2)
|
|
63
|
-
concurrent-ruby (1.0.
|
|
63
|
+
concurrent-ruby (1.0.4)
|
|
64
64
|
coveralls (0.8.17)
|
|
65
65
|
json (>= 1.8, < 3)
|
|
66
66
|
simplecov (~> 0.12.0)
|
|
@@ -99,7 +99,7 @@ GEM
|
|
|
99
99
|
mime-types-data (3.2016.0521)
|
|
100
100
|
mini_portile2 (2.1.0)
|
|
101
101
|
minitest (5.10.1)
|
|
102
|
-
nokogiri (1.
|
|
102
|
+
nokogiri (1.7.0.1)
|
|
103
103
|
mini_portile2 (~> 2.1.0)
|
|
104
104
|
orm_adapter (0.5.0)
|
|
105
105
|
rack (1.6.5)
|
|
@@ -118,9 +118,9 @@ GEM
|
|
|
118
118
|
sprockets-rails
|
|
119
119
|
rails-deprecated_sanitizer (1.0.3)
|
|
120
120
|
activesupport (>= 4.2.0.alpha)
|
|
121
|
-
rails-dom-testing (1.0.
|
|
121
|
+
rails-dom-testing (1.0.8)
|
|
122
122
|
activesupport (>= 4.2.0.beta, < 5.0)
|
|
123
|
-
nokogiri (~> 1.6
|
|
123
|
+
nokogiri (~> 1.6)
|
|
124
124
|
rails-deprecated_sanitizer (>= 1.0.1)
|
|
125
125
|
rails-html-sanitizer (1.0.3)
|
|
126
126
|
loofah (~> 2.0)
|
|
@@ -154,7 +154,7 @@ GEM
|
|
|
154
154
|
json (>= 1.8, < 3)
|
|
155
155
|
simplecov-html (~> 0.10.0)
|
|
156
156
|
simplecov-html (0.10.0)
|
|
157
|
-
slack-notifier (
|
|
157
|
+
slack-notifier (2.0.0)
|
|
158
158
|
sprockets (3.7.1)
|
|
159
159
|
concurrent-ruby (~> 1.0)
|
|
160
160
|
rack (> 1, < 3)
|
|
@@ -162,7 +162,7 @@ GEM
|
|
|
162
162
|
actionpack (>= 4.0)
|
|
163
163
|
activesupport (>= 4.0)
|
|
164
164
|
sprockets (>= 3.0.0)
|
|
165
|
-
sqlite3 (1.3.
|
|
165
|
+
sqlite3 (1.3.13)
|
|
166
166
|
term-ansicolor (1.4.0)
|
|
167
167
|
tins (~> 1.0)
|
|
168
168
|
thor (0.19.4)
|
|
@@ -190,8 +190,8 @@ DEPENDENCIES
|
|
|
190
190
|
rails (~> 4.2.0)
|
|
191
191
|
rspec-rails (~> 3.5.1)
|
|
192
192
|
simplecov (~> 0.12.0)
|
|
193
|
-
slack-notifier (
|
|
194
|
-
sqlite3 (~> 1.3.
|
|
193
|
+
slack-notifier (>= 1.5.1)
|
|
194
|
+
sqlite3 (~> 1.3.13)
|
|
195
195
|
timecop
|
|
196
196
|
yard (~> 0.9.5)
|
|
197
197
|
yard-activesupport-concern (~> 0.0.1)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ../
|
|
3
3
|
specs:
|
|
4
|
-
activity_notification (1.2.
|
|
4
|
+
activity_notification (1.2.1)
|
|
5
5
|
activerecord (>= 4.2.0)
|
|
6
6
|
i18n (>= 0.5.0)
|
|
7
7
|
jquery-rails (>= 3.1.1)
|
|
@@ -52,17 +52,17 @@ GEM
|
|
|
52
52
|
railties (>= 3.0)
|
|
53
53
|
rspec-rails (>= 2.2)
|
|
54
54
|
arel (7.1.4)
|
|
55
|
-
aws-sdk (2.6.
|
|
56
|
-
aws-sdk-resources (= 2.6.
|
|
57
|
-
aws-sdk-core (2.6.
|
|
55
|
+
aws-sdk (2.6.44)
|
|
56
|
+
aws-sdk-resources (= 2.6.44)
|
|
57
|
+
aws-sdk-core (2.6.44)
|
|
58
58
|
aws-sigv4 (~> 1.0)
|
|
59
59
|
jmespath (~> 1.0)
|
|
60
|
-
aws-sdk-resources (2.6.
|
|
61
|
-
aws-sdk-core (= 2.6.
|
|
60
|
+
aws-sdk-resources (2.6.44)
|
|
61
|
+
aws-sdk-core (= 2.6.44)
|
|
62
62
|
aws-sigv4 (1.0.0)
|
|
63
63
|
bcrypt (3.1.11)
|
|
64
64
|
builder (3.2.2)
|
|
65
|
-
concurrent-ruby (1.0.
|
|
65
|
+
concurrent-ruby (1.0.4)
|
|
66
66
|
coveralls (0.8.17)
|
|
67
67
|
json (>= 1.8, < 3)
|
|
68
68
|
simplecov (~> 0.12.0)
|
|
@@ -103,7 +103,7 @@ GEM
|
|
|
103
103
|
mini_portile2 (2.1.0)
|
|
104
104
|
minitest (5.10.1)
|
|
105
105
|
nio4r (1.2.1)
|
|
106
|
-
nokogiri (1.
|
|
106
|
+
nokogiri (1.7.0.1)
|
|
107
107
|
mini_portile2 (~> 2.1.0)
|
|
108
108
|
orm_adapter (0.5.0)
|
|
109
109
|
rack (2.0.1)
|
|
@@ -125,9 +125,9 @@ GEM
|
|
|
125
125
|
actionpack (~> 5.x)
|
|
126
126
|
actionview (~> 5.x)
|
|
127
127
|
activesupport (~> 5.x)
|
|
128
|
-
rails-dom-testing (2.0.
|
|
128
|
+
rails-dom-testing (2.0.2)
|
|
129
129
|
activesupport (>= 4.2.0, < 6.0)
|
|
130
|
-
nokogiri (~> 1.6
|
|
130
|
+
nokogiri (~> 1.6)
|
|
131
131
|
rails-html-sanitizer (1.0.3)
|
|
132
132
|
loofah (~> 2.0)
|
|
133
133
|
railties (5.0.1)
|
|
@@ -161,7 +161,7 @@ GEM
|
|
|
161
161
|
json (>= 1.8, < 3)
|
|
162
162
|
simplecov-html (~> 0.10.0)
|
|
163
163
|
simplecov-html (0.10.0)
|
|
164
|
-
slack-notifier (
|
|
164
|
+
slack-notifier (2.0.0)
|
|
165
165
|
sprockets (3.7.1)
|
|
166
166
|
concurrent-ruby (~> 1.0)
|
|
167
167
|
rack (> 1, < 3)
|
|
@@ -169,7 +169,7 @@ GEM
|
|
|
169
169
|
actionpack (>= 4.0)
|
|
170
170
|
activesupport (>= 4.0)
|
|
171
171
|
sprockets (>= 3.0.0)
|
|
172
|
-
sqlite3 (1.3.
|
|
172
|
+
sqlite3 (1.3.13)
|
|
173
173
|
term-ansicolor (1.4.0)
|
|
174
174
|
tins (~> 1.0)
|
|
175
175
|
thor (0.19.4)
|
|
@@ -201,8 +201,8 @@ DEPENDENCIES
|
|
|
201
201
|
rails-controller-testing
|
|
202
202
|
rspec-rails (~> 3.5.1)
|
|
203
203
|
simplecov (~> 0.12.0)
|
|
204
|
-
slack-notifier (
|
|
205
|
-
sqlite3 (~> 1.3.
|
|
204
|
+
slack-notifier (>= 1.5.1)
|
|
205
|
+
sqlite3 (~> 1.3.13)
|
|
206
206
|
timecop
|
|
207
207
|
yard (~> 0.9.5)
|
|
208
208
|
yard-activesupport-concern (~> 0.0.1)
|
|
@@ -6,27 +6,27 @@ module ActivityNotification
|
|
|
6
6
|
|
|
7
7
|
# Initialize method to prepare Slack::Notifier
|
|
8
8
|
# @param [Hash] options Options for initializing
|
|
9
|
-
# @option options [String, Proc, Symbol] :
|
|
10
|
-
# @option options [required, String] :webhook_url
|
|
11
|
-
# @option options [Hash] others
|
|
9
|
+
# @option options [String, Proc, Symbol] :target_username (nil) Target user name of Slack, it resolved by target instance like email_allowed?
|
|
10
|
+
# @option options [required, String] :webhook_url (nil) Webhook URL of Slack Incoming WebHooks integration
|
|
11
|
+
# @option options [Hash] others Other options to be set Slack::Notifier.new, like :channel, :username, :icon_emoji etc
|
|
12
12
|
def initialize_target(options = {})
|
|
13
|
-
@
|
|
13
|
+
@target_username = options.delete(:target_username)
|
|
14
14
|
@notifier = ::Slack::Notifier.new(options.delete(:webhook_url), options)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
# Publishes notification message to Slack
|
|
18
18
|
# @param [Notification] notification Notification instance
|
|
19
19
|
# @param [Hash] options Options for publishing
|
|
20
|
-
# @option options [String, Proc, Symbol] :
|
|
21
|
-
# @option options [String] :partial_root
|
|
22
|
-
# @option options [String] :partial
|
|
23
|
-
# @option options [String] :layout
|
|
24
|
-
# @option options [String] :layout_root
|
|
25
|
-
# @option options [String, Symbol] :fallback
|
|
26
|
-
# @option options [Hash] others
|
|
20
|
+
# @option options [String, Proc, Symbol] :target_username (nil) Target user name of Slack, it resolved by target instance like email_allowed?
|
|
21
|
+
# @option options [String] :partial_root ("activity_notification/optional_targets/#{target}/#{optional_target_name}", "activity_notification/optional_targets/#{target}/base", "activity_notification/optional_targets/default/#{optional_target_name}", "activity_notification/optional_targets/default/base") Partial template name
|
|
22
|
+
# @option options [String] :partial (self.key.tr('.', '/')) Root path of partial template
|
|
23
|
+
# @option options [String] :layout (nil) Layout template name
|
|
24
|
+
# @option options [String] :layout_root ('layouts') Root path of layout template
|
|
25
|
+
# @option options [String, Symbol] :fallback (:default) Fallback template to use when MissingTemplate is raised. Set :text to use i18n text as fallback.
|
|
26
|
+
# @option options [Hash] others Parameters to be set as locals
|
|
27
27
|
def notify(notification, options = {})
|
|
28
|
-
|
|
29
|
-
@notifier.ping(render_notification_message(notification, options.merge(assignment: {
|
|
28
|
+
target_username = notification.target.resolve_value(options.delete(:target_username) || @target_username)
|
|
29
|
+
@notifier.ping(render_notification_message(notification, options.merge(assignment: { target_username: target_username })))
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -12,21 +12,34 @@ class Comment < ActiveRecord::Base
|
|
|
12
12
|
printable_name: ->(comment) { "comment \"#{comment.body}\"" },
|
|
13
13
|
dependent_notifications: :update_group_and_delete_all
|
|
14
14
|
|
|
15
|
-
# require 'activity_notification/optional_targets/amazon_sns'
|
|
16
|
-
# require 'activity_notification/optional_targets/slack'
|
|
17
15
|
require 'custom_optional_targets/console_output'
|
|
16
|
+
optional_targets = { CustomOptionalTarget::ConsoleOutput => {} }
|
|
17
|
+
if ENV['OPTIONAL_TARGET_AMAZON_SNS']
|
|
18
|
+
require 'activity_notification/optional_targets/amazon_sns'
|
|
19
|
+
if ENV['OPTIONAL_TARGET_AMAZON_SNS_TOPIC_ARN']
|
|
20
|
+
optional_targets = optional_targets.merge(
|
|
21
|
+
ActivityNotification::OptionalTarget::AmazonSNS => { topic_arn: ENV['OPTIONAL_TARGET_AMAZON_SNS_TOPIC_ARN'] }
|
|
22
|
+
)
|
|
23
|
+
elsif ENV['OPTIONAL_TARGET_AMAZON_SNS_PHONE_NUMBER']
|
|
24
|
+
optional_targets = optional_targets.merge(
|
|
25
|
+
ActivityNotification::OptionalTarget::AmazonSNS => { phone_number: :phone_number }
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
if ENV['OPTIONAL_TARGET_SLACK']
|
|
30
|
+
require 'activity_notification/optional_targets/slack'
|
|
31
|
+
optional_targets = optional_targets.merge(
|
|
32
|
+
ActivityNotification::OptionalTarget::Slack => {
|
|
33
|
+
webhook_url: ENV['OPTIONAL_TARGET_SLACK_WEBHOOK_URL'], target_username: :slack_username,
|
|
34
|
+
channel: ENV['OPTIONAL_TARGET_SLACK_CHANNEL'] || 'activity_notification',
|
|
35
|
+
username: 'ActivityNotification', icon_emoji: ":ghost:"
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
end
|
|
18
39
|
acts_as_notifiable :admins, targets: Admin.all,
|
|
19
40
|
group: :article, notifier: :user, notifiable_path: :article_notifiable_path,
|
|
20
41
|
printable_name: ->(comment) { "comment \"#{comment.body}\"" }, dependent_notifications: :delete_all,
|
|
21
|
-
optional_targets:
|
|
22
|
-
# ActivityNotification::OptionalTarget::AmazonSNS => { topic_arn: 'arn:aws:sns:XXXXX:XXXXXXXXXXXX:XXXXX' },
|
|
23
|
-
# # ActivityNotification::OptionalTarget::AmazonSNS => { phone_number: :phone_number },
|
|
24
|
-
# ActivityNotification::OptionalTarget::Slack => {
|
|
25
|
-
# webhook_url: 'https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX',
|
|
26
|
-
# slack_name: :slack_name, channel: 'activity_notification', username: 'ActivityNotification', icon_emoji: ":ghost:"
|
|
27
|
-
# },
|
|
28
|
-
CustomOptionalTarget::ConsoleOutput => {}
|
|
29
|
-
}
|
|
42
|
+
optional_targets: optional_targets
|
|
30
43
|
|
|
31
44
|
def article_notifiable_path
|
|
32
45
|
article_path(article)
|
|
@@ -5,4 +5,6 @@ Dear <%= @target.printable_target_name %>
|
|
|
5
5
|
<%= @notification.notifier.present? ? @notification.notifier.printable_notifier_name : 'Someone' %> notified you of <%= @notification.notifiable.printable_notifiable_name(@notification.target) %><%= " in #{@notification.group.printable_group_name}" if @notification.group.present? %>.
|
|
6
6
|
|
|
7
7
|
<%= "Move to notified #{@notification.notifiable.printable_type.downcase}:" %>
|
|
8
|
-
<%= move_notification_url_for(@notification, open: true) %>
|
|
8
|
+
<%= move_notification_url_for(@notification, open: true) %>
|
|
9
|
+
|
|
10
|
+
Thank you!
|
data/spec/rails_app/db/schema.rb
CHANGED
|
@@ -15,7 +15,7 @@ ActiveRecord::Schema.define(version: 20160715050433) do
|
|
|
15
15
|
create_table "admins", force: :cascade do |t|
|
|
16
16
|
t.integer "user_id"
|
|
17
17
|
t.string "phone_number"
|
|
18
|
-
t.string "
|
|
18
|
+
t.string "slack_username"
|
|
19
19
|
t.datetime "created_at"
|
|
20
20
|
t.datetime "updated_at"
|
|
21
21
|
t.index ["user_id"], name: "index_admins_on_user_id"
|
data/spec/rails_app/db/seeds.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# This file is seed file for test data on development environment.
|
|
3
3
|
|
|
4
4
|
ActivityNotification::Notification.delete_all
|
|
5
|
+
ActivityNotification::Subscription.delete_all
|
|
5
6
|
Comment.delete_all
|
|
6
7
|
Article.delete_all
|
|
7
8
|
Admin.delete_all
|
|
@@ -21,7 +22,11 @@ end
|
|
|
21
22
|
|
|
22
23
|
['Ichiro'].each do |name|
|
|
23
24
|
user = User.find_by_name(name)
|
|
24
|
-
Admin.create(
|
|
25
|
+
Admin.create(
|
|
26
|
+
user: user,
|
|
27
|
+
phone_number: ENV['OPTIONAL_TARGET_AMAZON_SNS_PHONE_NUMBER'],
|
|
28
|
+
slack_username: ENV['OPTIONAL_TARGET_SLACK_USERNAME']
|
|
29
|
+
)
|
|
25
30
|
end
|
|
26
31
|
|
|
27
32
|
User.all.each do |user|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activity_notification
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shota Yamazaki
|
|
@@ -78,14 +78,14 @@ dependencies:
|
|
|
78
78
|
requirements:
|
|
79
79
|
- - "~>"
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: 1.3.
|
|
81
|
+
version: 1.3.13
|
|
82
82
|
type: :development
|
|
83
83
|
prerelease: false
|
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
85
|
requirements:
|
|
86
86
|
- - "~>"
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: 1.3.
|
|
88
|
+
version: 1.3.13
|
|
89
89
|
- !ruby/object:Gem::Dependency
|
|
90
90
|
name: rspec-rails
|
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -188,14 +188,14 @@ dependencies:
|
|
|
188
188
|
name: slack-notifier
|
|
189
189
|
requirement: !ruby/object:Gem::Requirement
|
|
190
190
|
requirements:
|
|
191
|
-
- - "
|
|
191
|
+
- - ">="
|
|
192
192
|
- !ruby/object:Gem::Version
|
|
193
193
|
version: 1.5.1
|
|
194
194
|
type: :development
|
|
195
195
|
prerelease: false
|
|
196
196
|
version_requirements: !ruby/object:Gem::Requirement
|
|
197
197
|
requirements:
|
|
198
|
-
- - "
|
|
198
|
+
- - ">="
|
|
199
199
|
- !ruby/object:Gem::Version
|
|
200
200
|
version: 1.5.1
|
|
201
201
|
description: Integrated user activity notifications for Ruby on Rails. Provides functions
|