summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/test_route.lua
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-13 13:42:49 -0400
committerPeter Kozak <spag@golwen.net>2013-03-13 13:42:49 -0400
commit1ea544f5d29d3bc43bf1d7ddfd1f7692f5cbcdda (patch)
treeff7a146021751c6369d85854018ccfef0179b826 /misc/freeswitch/scripts/test_route.lua
parentdc212986e401335fbd27216e029889f0cd941340 (diff)
retrieve destination and caller_id_numbers
Diffstat (limited to 'misc/freeswitch/scripts/test_route.lua')
-rw-r--r--misc/freeswitch/scripts/test_route.lua32
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));