From 1a9b4ef6d9ebbe77ba113d960d85c7097ae3368c Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 13 Mar 2013 06:49:40 -0400 Subject: transfer_blind method added --- app/models/call.rb | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'app/models/call.rb') diff --git a/app/models/call.rb b/app/models/call.rb index 8f657fa..61d10ce 100644 --- a/app/models/call.rb +++ b/app/models/call.rb @@ -39,6 +39,30 @@ class Call < ActiveRecord::Base return FreeswitchAPI.execute('uuid_kill', self.uuid, true); end + def transfer_blind(destination, call_leg=:aleg, auth_account=nil) + if destination.blank? + return nil + end + + if call_leg == :bleg + channel_uuid = self.b_uuid + else + channel_uuid = self.uuid + end + + if channel_uuid.blank? + return nil + end + + if auth_account + FreeswitchAPI.api('uuid_setvar', channel_uuid, 'gs_auth_account_type', auth_account.class.name) + FreeswitchAPI.api('uuid_setvar', channel_uuid, 'gs_auth_account_uuid', auth_account.uuid) + end + + require 'freeswitch_event' + return FreeswitchAPI.api_result(FreeswitchAPI.api('uuid_transfer', channel_uuid, destination)) + end + def get_variable_from_uuid(channel_uuid, variable_name) if channel_uuid.blank? return nil @@ -61,5 +85,5 @@ class Call < ActiveRecord::Base def get_variable_bleg(variable_name) return get_variable_from_uuid(self.b_uuid, variable_name); end - + end -- cgit v1.2.3 From 3e1092b532d34141d77f1e9176831e2bf82845ac Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 13 Mar 2013 10:03:01 -0400 Subject: load freeswitch_event module before use --- app/models/call.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/models/call.rb') diff --git a/app/models/call.rb b/app/models/call.rb index 61d10ce..a8a0d7f 100644 --- a/app/models/call.rb +++ b/app/models/call.rb @@ -54,12 +54,12 @@ class Call < ActiveRecord::Base return nil end + require 'freeswitch_event' if auth_account FreeswitchAPI.api('uuid_setvar', channel_uuid, 'gs_auth_account_type', auth_account.class.name) FreeswitchAPI.api('uuid_setvar', channel_uuid, 'gs_auth_account_uuid', auth_account.uuid) end - require 'freeswitch_event' return FreeswitchAPI.api_result(FreeswitchAPI.api('uuid_transfer', channel_uuid, destination)) end @@ -85,5 +85,5 @@ class Call < ActiveRecord::Base def get_variable_bleg(variable_name) return get_variable_from_uuid(self.b_uuid, variable_name); end - + end -- cgit v1.2.3