diff options
author | Peter Kozak <spag@golwen.net> | 2013-08-02 08:54:16 +0200 |
---|---|---|
committer | Peter Kozak <spag@golwen.net> | 2013-08-02 08:54:16 +0200 |
commit | 0bca4fde90142a598b348f6cbd12dd6bb32b6adc (patch) | |
tree | 1d5607919c58f9cd1585435ea3f95250767fc5f7 /misc/freeswitch/scripts/dialplan | |
parent | c43444a297eae48b431fc435301abac3fdea39cd (diff) |
enable callee_id in routing
Diffstat (limited to 'misc/freeswitch/scripts/dialplan')
-rw-r--r-- | misc/freeswitch/scripts/dialplan/dialplan.lua | 17 |
1 files 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 } |