summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/dialplan
diff options
context:
space:
mode:
Diffstat (limited to 'misc/freeswitch/scripts/dialplan')
-rw-r--r--misc/freeswitch/scripts/dialplan/dialplan.lua1
-rw-r--r--misc/freeswitch/scripts/dialplan/functions.lua14
-rw-r--r--misc/freeswitch/scripts/dialplan/sip_call.lua22
3 files changed, 27 insertions, 10 deletions
diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua
index b27bb9d..d82e6c0 100644
--- a/misc/freeswitch/scripts/dialplan/dialplan.lua
+++ b/misc/freeswitch/scripts/dialplan/dialplan.lua
@@ -375,6 +375,7 @@ function Dialplan.dial(self, destination)
if destination.account.class == 'sipaccount' then
destination.callee_id_name = destination.account.record.caller_name;
self.caller:set_callee_id(destination.number, destination.account.record.caller_name);
+ destination.pickup_groups = { 's' .. destination.account.id };
end
end
diff --git a/misc/freeswitch/scripts/dialplan/functions.lua b/misc/freeswitch/scripts/dialplan/functions.lua
index eddce74..b4ebf56 100644
--- a/misc/freeswitch/scripts/dialplan/functions.lua
+++ b/misc/freeswitch/scripts/dialplan/functions.lua
@@ -236,16 +236,12 @@ function Functions.intercept_any_number(self, caller, destination_number)
return { continue = false, code = 505, phrase = 'Incompatible destination', no_cdr = true };
end
- require 'common.sip_account'
- local sip_account = common.sip_account.SipAccount:new{ log = self.log, database = self.database }:find_by_id(phone_number.record.phone_numberable_id)
-
- if not sip_account then
- self.log:notice('FUNCTION_INTERCEPT_ANY_NUMBER - no sip_account found for number: ', destination_number);
- return { continue = false, code = 505, phrase = 'Incompatible destination', no_cdr = true };
- end
+ self.log:info('FUNCTION_INTERCEPT_ANY_NUMBER intercepting call - to: ', phone_number.record.phone_numberable_type:lower(), '=', phone_number.record.phone_numberable_id, ', number: ', destination_number);
- self.log:info('FUNCTION_INTERCEPT_ANY_NUMBER intercepting call - to: ', phone_number.record.phone_numberable_type:lower(), '=', phone_number.record.phone_numberable_id, ', name: ', sip_account.record.auth_name);
- return self:intercept_destination(caller, sip_account.record.auth_name);
+ caller:set_variable('gs_pickup_group_pick', 's' .. phone_number.record.phone_numberable_id);
+ caller:execute('pickup', 's' .. phone_number.record.phone_numberable_id);
+
+ return { continue = false, code = 200, phrase = 'OK', no_cdr = true }
end
diff --git a/misc/freeswitch/scripts/dialplan/sip_call.lua b/misc/freeswitch/scripts/dialplan/sip_call.lua
index e2d0da8..5c98792 100644
--- a/misc/freeswitch/scripts/dialplan/sip_call.lua
+++ b/misc/freeswitch/scripts/dialplan/sip_call.lua
@@ -76,7 +76,8 @@ end
function SipCall.fork(self, destinations, arg )
- local dial_strings = {}
+ local dial_strings = {};
+ local pickup_groups = {};
require 'common.sip_account'
require 'common.str'
@@ -135,6 +136,11 @@ function SipCall.fork(self, destinations, arg )
table.insert(origination_variables, "alert_info='" .. destination.alert_info .. "'");
end
table.insert(dial_strings, '[' .. table.concat(origination_variables , ',') .. ']sofia/' .. sip_account.record.profile_name .. '/' .. sip_account.record.auth_name .. '%' .. sip_account.record.sip_host);
+ if destination.pickup_groups and #destination.pickup_groups > 0 then
+ for key=1, #destination.pickup_groups do
+ pickup_groups[destination.pickup_groups[key]] = true;
+ end
+ end
else
some_destinations_busy = true;
call_result = { code = 486, phrase = 'User busy', disposition = 'USER_BUSY' };
@@ -184,6 +190,10 @@ function SipCall.fork(self, destinations, arg )
self.caller:set_variable('call_timeout', arg.timeout );
self.log:info('FORK DIAL - destinations: ', #dial_strings, ', timeout: ', arg.timeout);
+ for pickup_group, value in pairs(pickup_groups) do
+ table.insert(dial_strings, 'pickup/' .. pickup_group);
+ end
+
if arg.send_ringing then
self.caller:execute('ring_ready');
end
@@ -201,6 +211,16 @@ function SipCall.fork(self, destinations, arg )
fork_index = tonumber(session_callee:getVariable('gs_fork_index')) or 0;
local destination = destinations[fork_index];
+ if not destination then
+ destination = {
+ ['type'] = session_callee:getVariable('gs_account_type');
+ id = session_callee:getVariable('gs_account_id');
+ uuid = session_callee:getVariable('gs_account_uuid');
+ pickup_group_pick = session_callee:getVariable('gs_pickup_group_pick');
+ }
+ self.log:notice('FORK - call picked off by: ', destination.type, '=', destination.id, '/', destination.uuid, ', pickup_group: ', destination.pickup_group_pick);
+ end
+
if arg.detect_dtmf_after_bridge_caller and self.caller.auth_account then
session:execute('start_dtmf');
end