Add. Use params in directory.lua (#2157)
This commit is contained in:
parent
7f8173f4ad
commit
d65ee95d9c
|
|
@ -36,8 +36,14 @@
|
||||||
require "resources.functions.config";
|
require "resources.functions.config";
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
require "resources.functions.database_handle";
|
local Database = require "resources.functions.database";
|
||||||
dbh = database_handle('system');
|
dbh = Database.new('system');
|
||||||
|
|
||||||
|
--include json library
|
||||||
|
local json
|
||||||
|
if (debug["sql"]) then
|
||||||
|
json = require "resources.functions.lunajson"
|
||||||
|
end
|
||||||
|
|
||||||
--include functions
|
--include functions
|
||||||
require "resources.functions.format_ringback"
|
require "resources.functions.format_ringback"
|
||||||
|
|
@ -91,7 +97,7 @@
|
||||||
--get the domain info
|
--get the domain info
|
||||||
domain_name = session:getVariable("domain_name");
|
domain_name = session:getVariable("domain_name");
|
||||||
domain_uuid = session:getVariable("domain_uuid");
|
domain_uuid = session:getVariable("domain_uuid");
|
||||||
|
|
||||||
--get the timeout destination
|
--get the timeout destination
|
||||||
timeout_destination = session:getVariable("timeout_destination");
|
timeout_destination = session:getVariable("timeout_destination");
|
||||||
|
|
||||||
|
|
@ -126,12 +132,13 @@
|
||||||
--get the domain_uuid
|
--get the domain_uuid
|
||||||
if (domain_uuid == nil) then
|
if (domain_uuid == nil) then
|
||||||
if (domain_name ~= nil) then
|
if (domain_name ~= nil) then
|
||||||
sql = "SELECT domain_uuid FROM v_domains ";
|
local sql = "SELECT domain_uuid FROM v_domains ";
|
||||||
sql = sql .. "WHERE domain_name = '" .. domain_name .."' ";
|
sql = sql .. "WHERE domain_name = :domain_name";
|
||||||
|
local params = {domain_name = domain_name};
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("notice", "[conference] SQL: " .. sql .. "\n");
|
freeswitch.consoleLog("notice", "[directory] SQL: " .. sql .. "; params: " .. json.encode(params) .. "\n");
|
||||||
end
|
end
|
||||||
status = dbh:query(sql, function(rows)
|
dbh:query(sql, params, function(rows)
|
||||||
domain_uuid = string.lower(rows["domain_uuid"]);
|
domain_uuid = string.lower(rows["domain_uuid"]);
|
||||||
end);
|
end);
|
||||||
end
|
end
|
||||||
|
|
@ -226,16 +233,16 @@
|
||||||
if (row.first_name) then
|
if (row.first_name) then
|
||||||
--play the recorded name
|
--play the recorded name
|
||||||
if (storage_type == "base64") then
|
if (storage_type == "base64") then
|
||||||
local Database = require "resources.functions.database";
|
|
||||||
local dbh = Database.new('system', 'base64/read')
|
local dbh = Database.new('system', 'base64/read')
|
||||||
|
|
||||||
sql = [[SELECT * FROM v_voicemails
|
local sql = [[SELECT * FROM v_voicemails
|
||||||
WHERE domain_uuid = ']] .. domain_uuid ..[['
|
WHERE domain_uuid = :domain_uuid
|
||||||
AND voicemail_id = ']].. row.extension.. [[' ]];
|
AND voicemail_id = :voicemail_id]];
|
||||||
|
local params = {domain_uuid = domain_uuid, voicemail_id = row.extension};
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("notice", "[directory] SQL: " .. sql .. "\n");
|
freeswitch.consoleLog("notice", "[directory] SQL: " .. sql .. "; params: " .. json.encode(params) .. "\n");
|
||||||
end
|
end
|
||||||
status = dbh:query(sql, function(field)
|
dbh:query(sql, params, function(field)
|
||||||
--set the voicemail message path
|
--set the voicemail message path
|
||||||
file_location = voicemail_dir.."/"..row.extension.."/recorded_name.wav";
|
file_location = voicemail_dir.."/"..row.extension.."/recorded_name.wav";
|
||||||
|
|
||||||
|
|
@ -327,13 +334,14 @@
|
||||||
end
|
end
|
||||||
|
|
||||||
--get the extensions from the database
|
--get the extensions from the database
|
||||||
sql = "SELECT * FROM v_extensions WHERE domain_uuid = '" .. domain_uuid .. "' AND enabled = 'true' AND (directory_visible is null or directory_visible = 'true'); ";
|
local sql = "SELECT * FROM v_extensions WHERE domain_uuid = :domain_uuid AND enabled = 'true' AND (directory_visible is null or directory_visible = 'true'); ";
|
||||||
|
local params = {domain_uuid = domain_uuid};
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("notice", "[directory] SQL: " .. sql .. "\n");
|
freeswitch.consoleLog("notice", "[directory] SQL: " .. sql .. "; params: " .. json.encode(params) .. "\n");
|
||||||
end
|
end
|
||||||
x = 1;
|
x = 1;
|
||||||
directory = {}
|
directory = {}
|
||||||
dbh:query(sql, function(row)
|
dbh:query(sql, params, function(row)
|
||||||
--show all key value pairs
|
--show all key value pairs
|
||||||
--for key, val in pairs(row) do
|
--for key, val in pairs(row) do
|
||||||
-- freeswitch.consoleLog("notice", "[directory] Key: " .. key .. " Value: " .. val .. "\n");
|
-- freeswitch.consoleLog("notice", "[directory] Key: " .. key .. " Value: " .. val .. "\n");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue