Reduce one request to the database and create a better domains array
This commit is contained in:
parent
84f17cd316
commit
d9f6d900e4
|
|
@ -41,32 +41,27 @@
|
||||||
--exits the script if we didn't connect properly
|
--exits the script if we didn't connect properly
|
||||||
assert(dbh:connected());
|
assert(dbh:connected());
|
||||||
|
|
||||||
--get the domain_uuid
|
|
||||||
if (domain_uuid == nil) then
|
|
||||||
--get the domain_uuid
|
|
||||||
if (domain_name ~= nil) then
|
|
||||||
sql = "SELECT domain_uuid FROM v_domains ";
|
|
||||||
sql = sql .. "WHERE domain_name = '" .. domain_name .."' ";
|
|
||||||
if (debug["sql"]) then
|
|
||||||
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
|
|
||||||
end
|
|
||||||
status = dbh:query(sql, function(rows)
|
|
||||||
domain_uuid = rows["domain_uuid"];
|
|
||||||
end);
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--get the domains
|
--get the domains
|
||||||
x = 1;
|
x = 1;
|
||||||
domains = {}
|
domains = {}
|
||||||
sql = "SELECT * FROM v_domains;";
|
sql = "SELECT * FROM v_domains;";
|
||||||
dbh:query(sql, function(row)
|
dbh:query(sql, function(row)
|
||||||
--add the entire row to the directory table array
|
--add items to the domains array
|
||||||
domains[x] = row;
|
domains[row["domain_name"]] = row["domain_uuid"];
|
||||||
|
domains[row["domain_uuid"]] = row["domain_name"];
|
||||||
--increment x
|
--increment x
|
||||||
x = x + 1;
|
x = x + 1;
|
||||||
end);
|
end);
|
||||||
|
|
||||||
|
--get the domain_uuid
|
||||||
|
if (domain_uuid == nil) then
|
||||||
|
--get the domain_uuid
|
||||||
|
if (domain_name ~= nil) then
|
||||||
|
domain_uuid = domains[domain_name];
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--get the domain name
|
--get the domain name
|
||||||
function get_domain_name(domains, domain_uuid)
|
function get_domain_name(domains, domain_uuid)
|
||||||
for key,value in ipairs(domains) do
|
for key,value in ipairs(domains) do
|
||||||
|
|
@ -261,8 +256,9 @@
|
||||||
if (call_context == "public") then
|
if (call_context == "public") then
|
||||||
if (dialplan_detail_tag == "action") then
|
if (dialplan_detail_tag == "action") then
|
||||||
if (first_action) then
|
if (first_action) then
|
||||||
if (domain_uuid ~= nil) then
|
if (domain_uuid ~= nil and domain_uuid ~= '') then
|
||||||
domain_name = get_domain_name(domains, domain_uuid);
|
--domain_name = get_domain_name(domains, domain_uuid);
|
||||||
|
domain_name = domains[domain_uuid];
|
||||||
table.insert(xml, [[ <action application="set" data="call_direction=inbound"/>]]);
|
table.insert(xml, [[ <action application="set" data="call_direction=inbound"/>]]);
|
||||||
table.insert(xml, [[ <action application="set" data="domain_uuid=]] .. domain_uuid .. [["/>]]);
|
table.insert(xml, [[ <action application="set" data="domain_uuid=]] .. domain_uuid .. [["/>]]);
|
||||||
table.insert(xml, [[ <action application="set" data="domain_name=]] .. domain_name .. [["/>]]);
|
table.insert(xml, [[ <action application="set" data="domain_name=]] .. domain_name .. [["/>]]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue