Skip to content
This repository was archived by the owner on Jan 31, 2019. It is now read-only.

Commit 10f4ea8

Browse files
committed
Notifo uses secrets
1 parent e5e7fb3 commit 10f4ea8

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

docs/github_payload

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# example params hash sinatra receives
22

3-
{
3+
{
44
"data" => {
5-
"apisecret" => "",
6-
"subscribers" => "" #CSV list
5+
"subscribers" => "" #CSV list
76
},
87

98
"payload" => {
@@ -27,7 +26,7 @@
2726
"url" => "http://github.com/mojombo/grit/commit/06f63b43050935962f84fe54473a7c5de7977325",
2827
"author" => { "name" => "Tom Preston-Werner", "email" => "tom@mojombo.com" },
2928
"id" => "06f63b43050935962f84fe54473a7c5de7977325"
30-
},
29+
},
3130
{
3231
"removed" => [],
3332
"message" => "clean up heads test",

docs/notifo

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ Install Notes
1111
3. Enjoy.
1212

1313
Notifications are only sent after the service (GitHub) has been approved to send you notifications on Notifo. This happens after the first commit after this service is enabled. You will begin receiving commit notifications from then on.
14-
14+
1515

1616
Developer Notes
1717
---------------
1818

1919
data
20-
- apisecret (hidden - add manually and do not list in source on github-services repo)
2120
- subscribers (csv list of up to 25 Notifo usernames)
2221

2322
payload

services/notifo.rb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1+
secrets = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'config', 'secrets.yml'))
2+
13
service :notifo do |data, payload|
2-
4+
35
subscribe_url = URI.parse('https://api.notifo.com/v1/subscribe_user')
46
data['subscribers'].gsub(/\s/, '').split(',').each do |subscriber|
57
req = Net::HTTP::Post.new(subscribe_url.path)
6-
req.basic_auth('github', data['apisecret'])
8+
req.basic_auth('github', secrets['notifo']['apikey'])
79
req.set_form_data('username' => subscriber)
8-
net = Net::HTTP.new(subscribe_url.host, 443)
10+
net = Net::HTTP.new(subscribe_url.host, 443)
911
net.use_ssl = true
1012
net.verify_mode = OpenSSL::SSL::VERIFY_NONE
1113
net.start {|http| http.request(req)}
12-
14+
1315
notification_url = URI.parse('https://api.notifo.com/v1/send_notification')
1416
payload['commits'].each do |commit|
1517
req = Net::HTTP::Post.new(notification_url.path)
16-
req.basic_auth('github', data['apisecret'])
18+
req.basic_auth('github', secrets['notifo']['apikey'])
1719
req.set_form_data(
1820
'to' => subscriber,
19-
'msg' => URI.escape("#{commit['author']['name']}: \"#{commit['message']}\"", Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")),
20-
'title' => URI.escape("#{payload['repository']['name']}/#{payload['ref_name']}", Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")),
21+
'msg' => URI.escape("#{commit['author']['name']}: \"#{commit['message']}\"", Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")),
22+
'title' => URI.escape("#{payload['repository']['name']}/#{payload['ref_name']}", Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")),
2123
'uri' => URI.escape(commit['url'], Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
2224
)
23-
net = Net::HTTP.new(notification_url.host, 443)
25+
net = Net::HTTP.new(notification_url.host, 443)
2426
net.use_ssl = true
2527
net.verify_mode = OpenSSL::SSL::VERIFY_NONE
2628
net.start {|http| http.request(req)}
2729
end
28-
30+
2931
end
3032

3133
end

0 commit comments

Comments
 (0)