diff options
Diffstat (limited to 'misc/freeswitch/scripts/test_route.lua')
-rw-r--r-- | misc/freeswitch/scripts/test_route.lua | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/misc/freeswitch/scripts/test_route.lua b/misc/freeswitch/scripts/test_route.lua index 4ff10b5..9ab00f7 100644 --- a/misc/freeswitch/scripts/test_route.lua +++ b/misc/freeswitch/scripts/test_route.lua @@ -22,9 +22,10 @@ function caller.to_s(variable) return common.str.to_s(arguments[variable]) end +local log_buffer = {}; -- initialize logging require 'common.log'; -log = common.log.Log:new{ disabled = true }; +log = common.log.Log:new{ buffer = log_buffer, prefix = '' }; -- connect to database require 'common.database'; @@ -42,12 +43,35 @@ caller.dialplan = dialplan_object; caller.local_node_id = dialplan_object.node_id; dialplan_object:retrieve_caller_data(); +local destination = arguments.destination or dialplan_object:destination_new{ number = caller.destination_number }; +local routes = {}; -require 'dialplan.router'; -local routes = dialplan.router.Router:new{ log = log, database = database, caller = caller, variables = caller }:route_run(arguments.table or 'outbound'); +if destination.type == 'unknown' then + local clip_no_screening = common.array.try(caller, 'account.record.clip_no_screening'); + caller.caller_id_numbers = {} + if not common.str.blank(clip_no_screening) then + for index, number in ipairs(common.str.strip_to_a(clip_no_screening, ',')) do + table.insert(caller.caller_id_numbers, number); + end + end + if caller.caller_phone_numbers then + for index, number in ipairs(caller.caller_phone_numbers) do + table.insert(caller.caller_id_numbers, number); + end + end + log:info('CALLER_ID_NUMBERS - clir: ', caller.clir, ', numbers: ', table.concat(caller.caller_id_numbers, ',')); + + destination.callee_id_number = destination.number; + destination.callee_id_name = nil; + + require 'dialplan.router'; + routes = dialplan.router.Router:new{ log = log, database = database, caller = caller, variables = caller, log_details = true }:route_run(arguments.table or 'outbound'); +end local result = { - routes = routes + routes = routes, + destination = destination, + log = log_buffer } stream:write(common.array.to_json(result)); |