Fix a problem with inbound calls and improve the dialplan lua script.

This commit is contained in:
Mark Crane
2014-02-22 18:06:30 +00:00
parent d1f7c87565
commit 87a79a9211

View File

@@ -37,35 +37,48 @@
local domain_name = session:getVariable("domain_name");
--determine the call direction
if (context == "public") then
call_direction = "inbound";
else
if (call_direction == nil) then
if (context == "outbound@"..domain_name) then
call_direction = "outbound";
if (call_direction == nil) then
--get the call directory
if (context == "public") then
call_direction = "inbound";
else
if (string.len(destination_number) > 6) then
if (context == "outbound@"..domain_name) then
call_direction = "outbound";
else
call_direction = "local";
if (string.len(destination_number) > 6) then
call_direction = "outbound";
else
call_direction = "local";
end
end
end
end
--set the call direction as a session variable
session:setVariable("call_direction", call_direction);
--freeswitch.consoleLog("notice", "[app:dialplan] set call_direction " .. call_direction .. "\n");
end
--set the call direction as a session variable
session:setVariable("call_direction", call_direction);
--freeswitch.consoleLog("notice", "[app:dialplan] set call_direction " .. call_direction .. "\n");
--determine the directory to include
if (context == "public") then
dialplan_dir = "inbound";
else
if (context == "outbound@"..domain_name) then
dialplan_dir = "outbound";
else
if (string.len(destination_number) > 6) then
dialplan_dir = "outbound";
else
dialplan_dir = "local";
end
end
end
--include the dialplans
result = assert (io.popen ("dir " ..scripts_dir.."/app/dialplan/resources/"..call_direction.." /b -1"));
result = assert (io.popen ("dir " ..scripts_dir.."/app/dialplan/resources/"..dialplan_dir.." /b -1"));
for file in result:lines() do
if (string.sub(file, -4) == ".lua") then
--order = string.match(file, "%d+");
--if (order == nil) then order = file; end
if file_exists(scripts_dir.."/app/dialplan/resources/"..call_direction.."/"..file) then
dofile(scripts_dir.."/app/dialplan/resources/"..call_direction.."/"..file);
if file_exists(scripts_dir.."/app/dialplan/resources/"..dialplan_dir.."/"..file) then
dofile(scripts_dir.."/app/dialplan/resources/"..dialplan_dir.."/"..file);
end
freeswitch.consoleLog("notice", "[app:dialplan] lua: " .. file .. "\n");
freeswitch.consoleLog("notice", "[app:dialplan] lua: "..dialplan_dir.."/" .. file .. "\n");
end
end