This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# A complete URL-shortening web application, written in Ruby/Sinatra. Run it | |
# from the command line, and then visit http://localhost:4567/ | |
# | |
# Or to run it under apache/passenger, you'll need a config.ru file with the | |
# following contents: | |
# | |
# require 'tinyurl' | |
# run Sinatra::Application |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post '/answer' do | |
user = params[:user] | |
if user == "voicemail" | |
notifier.ping "Call from: " + $redis.hget("call:#{params[:callId]}","from") + ". Hotline off.", | |
attachments: [call_details] | |
end | |
end | |
post '/hangup' do | |
hangupCause = "#{params[:cause]}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post '/' do | |
phonenumber = params[:from] | |
$redis.hset("call:#{params[:callId]}","from",phonenumber[0...-3]+'XXX') | |
headers 'Content-Type' => "application/xml" | |
xml = Builder::XmlMarkup.new(:indent => 2) | |
xml.instruct! | |
xml.Response("onAnswer" => settings.responseUrl + "answer", | |
"onHangup" => settings.responseUrl + "hangup") | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'slack-notifier' | |
require 'sinatra' | |
require 'builder' | |
require 'redis' | |
notifier = Slack::Notifier.new "https://hooks.slack.com/services/XXXXXXX/XXXXXXX/XXXXXXX" | |
call_details = { | |
fallback: "Call Details in the team <https://secure.live.sipgate.co.uk/|event list>.", | |
text: "Call Details in the team <https://secure.live.sipgate.co.uk/|event list>.", |