From 0bca4fde90142a598b348f6cbd12dd6bb32b6adc Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 2 Aug 2013 08:54:16 +0200 Subject: enable callee_id in routing --- misc/freeswitch/scripts/dialplan/dialplan.lua | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 0f61021..1133f58 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -729,14 +729,6 @@ function Dialplan.switch(self, destination) destination.callee_id_number = destination.number; destination.callee_id_name = nil; - require 'dialplan.router' - local routes = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('outbound'); - - if not routes or #routes == 0 then - self.log:notice('SWITCH - no route - number: ', destination.number); - return { continue = false, code = 404, phrase = 'No route' } - end - if self.phonebook_number_lookup then local user_id = common.array.try(self.caller, 'account.owner.id'); local tenant_id = common.array.try(self.caller, 'account.owner.record.current_tenant_id'); @@ -766,7 +758,16 @@ function Dialplan.switch(self, destination) self.caller:set_callee_id(destination.callee_id_number, destination.callee_id_name); + require 'dialplan.router' + local routes = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('outbound'); + + if not routes or #routes == 0 then + self.log:notice('SWITCH - no route - number: ', destination.number); + return { continue = false, code = 404, phrase = 'No route' } + end + for index, route in ipairs(routes) do + self.caller:set_callee_id(route.callee_id_number or destination.callee_id_number, route.callee_id_name or destination.callee_id_name); if route.type == 'hangup' then self.log:notice('SWITCH_HANGUP - code: ', route.code, ', phrase: ', route.phrase, ', cause: ', route.cause); return { continue = false, code = route.code or '404', phrase = route.phrase, cause = route.cause } -- cgit v1.2.3