mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-05 11:13:50 +00:00
Update directory.lua
This commit is contained in:
@@ -117,10 +117,10 @@
|
||||
-- variable. So if we have no such variable we do not need build dial-string.
|
||||
dialed_extension = params:getHeader("dialed_extension");
|
||||
if (dialed_extension == nil) then
|
||||
-- freeswitch.consoleLog("notice", "[xml_handler-directory.lua] dialed_extension is null\n");
|
||||
-- freeswitch.consoleLog("notice", "[xml_handler][directory] dialed_extension is null\n");
|
||||
USE_FS_PATH = false;
|
||||
else
|
||||
-- freeswitch.consoleLog("notice", "[xml_handler-directory.lua] dialed_extension is " .. dialed_extension .. "\n");
|
||||
-- freeswitch.consoleLog("notice", "[xml_handler][directory] dialed_extension is " .. dialed_extension .. "\n");
|
||||
end
|
||||
|
||||
-- verify from_user and number alias for this methods
|
||||
@@ -156,9 +156,9 @@
|
||||
|
||||
if debug['cache'] then
|
||||
if not XML_STRING then
|
||||
freeswitch.consoleLog("notice", "[xml_handler-directory][cache] get key: " .. key .. " fail: " .. tostring(err) .. "\n")
|
||||
freeswitch.consoleLog("notice", "[xml_handler][directory][cache] get key: " .. key .. " fail: " .. tostring(err) .. "\n")
|
||||
else
|
||||
freeswitch.consoleLog("notice", "[xml_handler-directory][cache] get key: " .. key .. " pass!" .. "\n")
|
||||
freeswitch.consoleLog("notice", "[xml_handler][directory][cache] get key: " .. key .. " pass!" .. "\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -167,7 +167,7 @@
|
||||
|
||||
--show the params in the console
|
||||
--if (params:serialize() ~= nil) then
|
||||
-- freeswitch.consoleLog("notice", "[xml_handler-directory.lua] Params:\n" .. params:serialize() .. "\n");
|
||||
-- freeswitch.consoleLog("notice", "[xml_handler][directory] Params:\n" .. params:serialize() .. "\n");
|
||||
--end
|
||||
|
||||
local loaded_from_db = false
|
||||
@@ -227,7 +227,7 @@
|
||||
|
||||
--get the caller hostname
|
||||
local_hostname = trim(api:execute("switchname", ""));
|
||||
--freeswitch.consoleLog("notice", "[xml_handler-directory.lua] local_hostname is " .. local_hostname .. "\n");
|
||||
--freeswitch.consoleLog("notice", "[xml_handler][directory] local_hostname is " .. local_hostname .. "\n");
|
||||
|
||||
--add the file_exists function
|
||||
require "resources.functions.file_exists";
|
||||
@@ -259,7 +259,7 @@
|
||||
database_hostname = row["hostname"];
|
||||
end);
|
||||
--freeswitch.consoleLog("notice", "[xml_handler] sql: " .. sql .. "\n");
|
||||
--freeswitch.consoleLog("notice", "[xml_handler-directory.lua] database_hostname is " .. database_hostname .. "\n");
|
||||
--freeswitch.consoleLog("notice", "[xml_handler][directory] database_hostname is " .. database_hostname .. "\n");
|
||||
|
||||
--hostname was not found set USE_FS_PATH to false to prevent a database_hostname concatenation error
|
||||
if (database_hostname == nil) then
|
||||
@@ -389,16 +389,16 @@
|
||||
--set the an alternative dial string if the hostnames don't match
|
||||
if (USE_FS_PATH) then
|
||||
if (local_hostname == database_hostname) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler-directory.lua] local_host and database_host are the same\n");
|
||||
freeswitch.consoleLog("notice", "[xml_handler][directory] local_host and database_host are the same\n");
|
||||
else
|
||||
contact = trim(api:execute("sofia_contact", destination));
|
||||
array = explode('/',contact);
|
||||
local profile, proxy = array[2], database_hostname;
|
||||
dial_string = "{sip_invite_domain=" .. domain_name .. ",presence_id=" .. presence_id .."}sofia/" .. profile .. "/" .. destination .. ";fs_path=sip:" .. proxy;
|
||||
--freeswitch.consoleLog("notice", "[xml_handler-directory.lua] dial_string " .. dial_string .. "\n");
|
||||
--freeswitch.consoleLog("notice", "[xml_handler][directory] dial_string " .. dial_string .. "\n");
|
||||
end
|
||||
else
|
||||
--freeswitch.consoleLog("notice", "[xml_handler-directory.lua] seems balancing is false??" .. tostring(USE_FS_PATH) .. "\n");
|
||||
--freeswitch.consoleLog("notice", "[xml_handler][directory] seems balancing is false??" .. tostring(USE_FS_PATH) .. "\n");
|
||||
end
|
||||
|
||||
--show debug informationa
|
||||
@@ -659,21 +659,21 @@
|
||||
if cache.support() then
|
||||
local key = "directory:" .. sip_from_number .. "@" .. domain_name
|
||||
if debug['cache'] then
|
||||
freeswitch.consoleLog("notice", "[xml_handler-directory][memcache] set key: " .. key .. "\n")
|
||||
freeswitch.consoleLog("notice", "[xml_handler][directory][cache] set key: " .. key .. "\n")
|
||||
end
|
||||
local ok, err = cache.set(key, XML_STRING, expire["directory"])
|
||||
if debug["cache"] and not ok then
|
||||
freeswitch.consoleLog("warning", "[xml_handler-directory][memcache] set key: " .. key .. " fail: " .. tostring(err) .. "\n");
|
||||
freeswitch.consoleLog("warning", "[xml_handler][directory][cache] set key: " .. key .. " fail: " .. tostring(err) .. "\n");
|
||||
end
|
||||
|
||||
if sip_from_number ~= sip_from_user then
|
||||
key = "directory:" .. sip_from_user .. "@" .. domain_name
|
||||
if debug['cache'] then
|
||||
freeswitch.consoleLog("notice", "[xml_handler-directory][memcache] set key: " .. key .. "\n")
|
||||
freeswitch.consoleLog("notice", "[xml_handler][directory][cache] set key: " .. key .. "\n")
|
||||
end
|
||||
ok, err = cache.set(key, XML_STRING, expire["directory"])
|
||||
if debug["cache"] and not ok then
|
||||
freeswitch.consoleLog("warning", "[xml_handler-directory][memcache] set key: " .. key .. " fail: " .. tostring(err) .. "\n");
|
||||
freeswitch.consoleLog("warning", "[xml_handler][directory][cache] set key: " .. key .. " fail: " .. tostring(err) .. "\n");
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -716,7 +716,7 @@
|
||||
--send to the console
|
||||
if (debug["cache"]) then
|
||||
if (XML_STRING) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] directory:" .. user .. "@" .. domain_name .. " source: memcache \n");
|
||||
freeswitch.consoleLog("notice", "[xml_handler] directory:" .. user .. "@" .. domain_name .. " source: cache \n");
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user