From 0a976c6b463288df4a9516bbd08f6232a37d427c Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 26 Feb 2013 09:21:34 -0500 Subject: enable tel: handling for sip_accounts --- app/controllers/sip_accounts_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/controllers/sip_accounts_controller.rb') diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index b5c3ae4..2886c8b 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -10,6 +10,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 +75,10 @@ class SipAccountsController < ApplicationController redirect_to :root, :notice => t('sip_accounts.controller.successfuly_destroyed') end + def call + redirect_to(:back) + end + private def set_and_authorize_parent @parent = @user || @tenant -- cgit v1.2.3 From 0399b856c75b842f43bc5380f9c19a64c6418f11 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 26 Feb 2013 10:00:36 -0500 Subject: call action added --- app/controllers/sip_accounts_controller.rb | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'app/controllers/sip_accounts_controller.rb') diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index 2886c8b..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 @@ -76,7 +77,33 @@ class SipAccountsController < ApplicationController end def call - redirect_to(:back) + 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 => "", + ) + return; + end + render( + :status => 404, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) + return; + end + + render( + :status => 404, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) end private -- cgit v1.2.3 From fc535da83c53f37fbc03caf72f61c01494ba6048 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 26 Feb 2013 17:31:13 +0100 Subject: load_resource :sip_account, :only => [:call] --- app/controllers/sip_accounts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers/sip_accounts_controller.rb') diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index 022858c..ef1aab8 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -1,7 +1,7 @@ class SipAccountsController < ApplicationController load_resource :user load_resource :tenant - #load_resource :sip_account + load_resource :sip_account, :only => [:call] load_and_authorize_resource :sip_account, :through => [:user, :tenant ] before_filter :set_and_authorize_parent -- cgit v1.2.3 From 41e17e9f3e184975e8b429d3fb06d822c49068bf Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 27 Feb 2013 10:43:17 +0100 Subject: load_and_authorize_resource :sip_account, :only => [:call] #213 --- app/controllers/sip_accounts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers/sip_accounts_controller.rb') diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index ef1aab8..621bd3c 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -1,7 +1,7 @@ class SipAccountsController < ApplicationController load_resource :user load_resource :tenant - load_resource :sip_account, :only => [:call] + load_and_authorize_resource :sip_account, :only => [:call] load_and_authorize_resource :sip_account, :through => [:user, :tenant ] before_filter :set_and_authorize_parent -- cgit v1.2.3