mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-04 10:43:49 +00:00
Fix a problem with inbound calls and improve the dialplan lua script.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user