-
Notifications
You must be signed in to change notification settings - Fork 0
/
irv.rb
65 lines (60 loc) · 1.61 KB
/
irv.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require 'cgi'
require 'open-uri'
require 'json'
class Irv < Sinatra::Application
enable :logging, :dump_errors, :raise_errors
get '/' do
'IRV!'
end
# status:
# info
# lock_id:
# 8944080
# object_type:
# User
# user_id:
# 9444
# message_key:
# Locks/access
# place_id:
# 8944081
# object_id:
# 9444
# id:
# 2454295
# actor_type:
# User
# integration_id:
# 170
# action:
# access
# text_message:
# Mike Macaluso ([email protected]) accessed lock CoworkBuffalo Door 2.0
# message:
# Mike Macaluso ([email protected]) accessed lock CoworkBuffalo Door 2.0
# group_id:
# 8944078
# email:
# actor_id:
# 9444
post '/kisi' do
payload = JSON.parse(request.body.read)
RestClient.post ENV['SLACK_URL'], {
text: payload['message']
}.to_json, content_type: :json, accept: :json
end
# app=secure-woodland-9775&user=example%40example.com&url=http%3A%2F%2Fsecure-woodland-9775.herokuapp.com&head=4f20bdd&head_long=4f20bdd&prev_head=&git_log=%20%20*%20Michael%20Friis%3A%20add%20bar&release=v7
post '/heroku' do
notify ENV['SLACK_URL']
notify ENV['OTHER_SLACK_URL']
end
def notify(url)
RestClient.post url, {
username: 'irv',
icon_url: 'https://raw.githubusercontent.com/coworkbuffalo/irv/master/irv.jpg',
text: "#{params['user']} deployed #{params['release']} / <https://github.com/qrush/mxdesk/commit/#{params['head']}|#{params['head']}> of <#{params['url']}|#{params['app']}>: #{params['git_log']}",
channel: '#mxdesk'
}.to_json, content_type: :json, accept: :json
end
end