|
| 1 | +secrets = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'config', 'secrets.yml')) |
| 2 | + |
1 | 3 | service :notifo do |data, payload| |
2 | | - |
| 4 | + |
3 | 5 | subscribe_url = URI.parse('https://api.notifo.com/v1/subscribe_user') |
4 | 6 | data['subscribers'].gsub(/\s/, '').split(',').each do |subscriber| |
5 | 7 | req = Net::HTTP::Post.new(subscribe_url.path) |
6 | | - req.basic_auth('github', data['apisecret']) |
| 8 | + req.basic_auth('github', secrets['notifo']['apikey']) |
7 | 9 | req.set_form_data('username' => subscriber) |
8 | | - net = Net::HTTP.new(subscribe_url.host, 443) |
| 10 | + net = Net::HTTP.new(subscribe_url.host, 443) |
9 | 11 | net.use_ssl = true |
10 | 12 | net.verify_mode = OpenSSL::SSL::VERIFY_NONE |
11 | 13 | net.start {|http| http.request(req)} |
12 | | - |
| 14 | + |
13 | 15 | notification_url = URI.parse('https://api.notifo.com/v1/send_notification') |
14 | 16 | payload['commits'].each do |commit| |
15 | 17 | req = Net::HTTP::Post.new(notification_url.path) |
16 | | - req.basic_auth('github', data['apisecret']) |
| 18 | + req.basic_auth('github', secrets['notifo']['apikey']) |
17 | 19 | req.set_form_data( |
18 | 20 | '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}]")), |
21 | 23 | 'uri' => URI.escape(commit['url'], Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) |
22 | 24 | ) |
23 | | - net = Net::HTTP.new(notification_url.host, 443) |
| 25 | + net = Net::HTTP.new(notification_url.host, 443) |
24 | 26 | net.use_ssl = true |
25 | 27 | net.verify_mode = OpenSSL::SSL::VERIFY_NONE |
26 | 28 | net.start {|http| http.request(req)} |
27 | 29 | end |
28 | | - |
| 30 | + |
29 | 31 | end |
30 | 32 |
|
31 | 33 | end |
0 commit comments