summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-26 16:18:24 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-26 16:18:24 +0100
commit390fbe398bbf7e485d2a9960a62e60e4083fd1df (patch)
tree8779ba4653c1f98c89932e091f742dc2a798f328 /app/controllers
parentab2bf212ed91b1e9359f026ef8775de2238a49be (diff)
parent0399b856c75b842f43bc5380f9c19a64c6418f11 (diff)
Merge branch 'develop' of github.com:amooma/GS5 into develop
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/sip_accounts_controller.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb
index b5c3ae4..022858c 100644
--- a/app/controllers/sip_accounts_controller.rb
+++ b/app/controllers/sip_accounts_controller.rb
@@ -1,6 +1,7 @@
class SipAccountsController < ApplicationController
load_resource :user
load_resource :tenant
+ #load_resource :sip_account
load_and_authorize_resource :sip_account, :through => [:user, :tenant ]
before_filter :set_and_authorize_parent
@@ -10,6 +11,7 @@ class SipAccountsController < ApplicationController
end
def show
+ @register_tel_protocol = "#{request.protocol}#{request.host_with_port}/sip_accounts/#{@sip_account.try(:id)}/call?url=%s"
end
def new
@@ -74,6 +76,36 @@ class SipAccountsController < ApplicationController
redirect_to :root, :notice => t('sip_accounts.controller.successfuly_destroyed')
end
+ def call
+ if !params[:url].blank?
+ protocol, separator, phone_number = params[:url].partition(':')
+ if ! phone_number.blank?
+ @sip_account.call(phone_number)
+ render(
+ :status => 200,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- CALL -->",
+ )
+ return;
+ end
+ render(
+ :status => 404,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- Number not found -->",
+ )
+ return;
+ end
+
+ render(
+ :status => 404,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- Call URL not found -->",
+ )
+ end
+
private
def set_and_authorize_parent
@parent = @user || @tenant