Do not provide the XMl for registering an disabled extension and other changes to improve the code.
This commit is contained in:
parent
1c5f7d57d6
commit
4c293b7f9e
|
|
@ -81,12 +81,13 @@
|
||||||
--handle the directory
|
--handle the directory
|
||||||
if (XML_REQUEST["section"] == "directory" and key and user and domain_name) then
|
if (XML_REQUEST["section"] == "directory" and key and user and domain_name) then
|
||||||
--get the extension from the database
|
--get the extension from the database
|
||||||
sql = "SELECT * FROM v_extensions WHERE domain_uuid = '" .. domain_uuid .. "' and extension = '" .. user .. "'";
|
sql = "SELECT * FROM v_extensions WHERE domain_uuid = '" .. domain_uuid .. "' and extension = '" .. user .. "' and enabled = 'true' ";
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
|
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
|
||||||
end
|
end
|
||||||
dbh:query(sql, function(row)
|
dbh:query(sql, function(row)
|
||||||
--general
|
--general
|
||||||
|
domain_uuid = row.domain_uuid;
|
||||||
extension = row.extension;
|
extension = row.extension;
|
||||||
cidr = "";
|
cidr = "";
|
||||||
if (string.len(row.cidr) > 0) then
|
if (string.len(row.cidr) > 0) then
|
||||||
|
|
@ -119,6 +120,7 @@
|
||||||
mwi_account = row.mwi_account;
|
mwi_account = row.mwi_account;
|
||||||
auth_acl = row.auth_acl;
|
auth_acl = row.auth_acl;
|
||||||
--variables
|
--variables
|
||||||
|
sip_from_user = row.extension;
|
||||||
call_group = row.call_group;
|
call_group = row.call_group;
|
||||||
hold_music = row.hold_music;
|
hold_music = row.hold_music;
|
||||||
toll_allow = row.toll_allow;
|
toll_allow = row.toll_allow;
|
||||||
|
|
@ -148,12 +150,14 @@
|
||||||
end);
|
end);
|
||||||
|
|
||||||
--outbound hot desking - get the extension variables
|
--outbound hot desking - get the extension variables
|
||||||
sql = "SELECT * FROM v_extensions WHERE dial_domain = '" .. domain_name .. "' and dial_user = '" .. user .. "'";
|
sql = "SELECT * FROM v_extensions WHERE dial_domain = '" .. domain_name .. "' and dial_user = '" .. user .. "' and enabled = 'true' ";
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
|
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
|
||||||
end
|
end
|
||||||
dbh:query(sql, function(row)
|
dbh:query(sql, function(row)
|
||||||
--variables
|
--variables
|
||||||
|
domain_uuid = row.domain_uuid;
|
||||||
|
sip_from_user = row.extension;
|
||||||
call_group = row.call_group;
|
call_group = row.call_group;
|
||||||
hold_music = row.hold_music;
|
hold_music = row.hold_music;
|
||||||
toll_allow = row.toll_allow;
|
toll_allow = row.toll_allow;
|
||||||
|
|
@ -176,6 +180,7 @@
|
||||||
end);
|
end);
|
||||||
|
|
||||||
--set the xml array and then concatenate the array to a string
|
--set the xml array and then concatenate the array to a string
|
||||||
|
if (password) then
|
||||||
local xml = {}
|
local xml = {}
|
||||||
table.insert(xml, [[<?xml version="1.0" encoding="UTF-8" standalone="no"?>]]);
|
table.insert(xml, [[<?xml version="1.0" encoding="UTF-8" standalone="no"?>]]);
|
||||||
table.insert(xml, [[<document type="freeswitch/xml">]]);
|
table.insert(xml, [[<document type="freeswitch/xml">]]);
|
||||||
|
|
@ -213,6 +218,12 @@
|
||||||
table.insert(xml, [[ <param name="dial-string" value="]] .. dial_string .. [["/>]]);
|
table.insert(xml, [[ <param name="dial-string" value="]] .. dial_string .. [["/>]]);
|
||||||
table.insert(xml, [[ </params>]]);
|
table.insert(xml, [[ </params>]]);
|
||||||
table.insert(xml, [[ <variables>]]);
|
table.insert(xml, [[ <variables>]]);
|
||||||
|
table.insert(xml, [[ <variable name="domain_uuid" value="]] .. domain_uuid .. [["/>]]);
|
||||||
|
if (user_context ~= "default" and user_context ~= "public" and user_context ~= "features") then
|
||||||
|
table.insert(xml, [[ <variable name="domain_name" value="]] .. user_context .. [["/>]]);
|
||||||
|
end
|
||||||
|
table.insert(xml, [[ <variable name="caller_id_name" value="]] .. sip_from_user .. [["/>]]);
|
||||||
|
table.insert(xml, [[ <variable name="caller_id_number" value="]] .. sip_from_user .. [["/>]]);
|
||||||
if (string.len(call_group) > 0) then
|
if (string.len(call_group) > 0) then
|
||||||
table.insert(xml, [[ <variable name="call_group" value="]] .. call_group .. [["/>]]);
|
table.insert(xml, [[ <variable name="call_group" value="]] .. call_group .. [["/>]]);
|
||||||
end
|
end
|
||||||
|
|
@ -226,13 +237,9 @@
|
||||||
table.insert(xml, [[ <variable name="accountcode" value="]] .. accountcode .. [["/>]]);
|
table.insert(xml, [[ <variable name="accountcode" value="]] .. accountcode .. [["/>]]);
|
||||||
end
|
end
|
||||||
table.insert(xml, [[ <variable name="user_context" value="]] .. user_context .. [["/>]]);
|
table.insert(xml, [[ <variable name="user_context" value="]] .. user_context .. [["/>]]);
|
||||||
if (string.len(effective_caller_id_name) > 0) then --
|
if (string.len(effective_caller_id_name) > 0) then
|
||||||
if (extension == "1003") then
|
|
||||||
table.insert(xml, [[ <variable name="effective_caller_id_name" value="1002"/>]]);
|
|
||||||
else
|
|
||||||
table.insert(xml, [[ <variable name="effective_caller_id_name" value="]] .. effective_caller_id_name.. [["/>]]);
|
table.insert(xml, [[ <variable name="effective_caller_id_name" value="]] .. effective_caller_id_name.. [["/>]]);
|
||||||
end
|
end
|
||||||
end
|
|
||||||
if (string.len(effective_caller_id_number) > 0) then
|
if (string.len(effective_caller_id_number) > 0) then
|
||||||
table.insert(xml, [[ <variable name="effective_caller_id_number" value="]] .. effective_caller_id_number.. [["/>]]);
|
table.insert(xml, [[ <variable name="effective_caller_id_number" value="]] .. effective_caller_id_number.. [["/>]]);
|
||||||
end
|
end
|
||||||
|
|
@ -289,6 +296,16 @@
|
||||||
table.insert(xml, [[ </section>]]);
|
table.insert(xml, [[ </section>]]);
|
||||||
table.insert(xml, [[</document>]]);
|
table.insert(xml, [[</document>]]);
|
||||||
XML_STRING = table.concat(xml, "\n");
|
XML_STRING = table.concat(xml, "\n");
|
||||||
|
else
|
||||||
|
XML_STRING = "";
|
||||||
|
end
|
||||||
|
|
||||||
|
--send the xml to the console
|
||||||
|
if (debug["xml_string"]) then
|
||||||
|
local file = assert(io.open("/tmp/directory.xml", "w"));
|
||||||
|
file:write(XML_STRING);
|
||||||
|
file:close();
|
||||||
|
end
|
||||||
|
|
||||||
--send the xml to the console
|
--send the xml to the console
|
||||||
if (debug["xml_string"]) then
|
if (debug["xml_string"]) then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue