Add. Use params in eavesdrop.lua (#2124)
This commit is contained in:
parent
3aa3b4316d
commit
bb9e02267d
|
|
@ -36,14 +36,13 @@
|
||||||
require "resources.functions.file_exists";
|
require "resources.functions.file_exists";
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
if (file_exists(database_dir.."/core.db")) then
|
local Database = require "resources.functions.database"
|
||||||
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
|
local dbh = Database.new('switch')
|
||||||
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/core.db");
|
|
||||||
freeswitch.consoleLog("NOTICE", "[eavesdrop] using core.db\n");
|
--include json library
|
||||||
else
|
local json
|
||||||
require "resources.functions.database_handle";
|
if (debug["sql"]) then
|
||||||
dbh = database_handle('switch');
|
json = require "resources.functions.lunajson"
|
||||||
freeswitch.consoleLog("NOTICE", "[eavesdrop] using the database\n");
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--exits the script if we didn't connect properly
|
--exits the script if we didn't connect properly
|
||||||
|
|
@ -110,9 +109,12 @@
|
||||||
|
|
||||||
--check the database to get the uuid to eavesdrop on
|
--check the database to get the uuid to eavesdrop on
|
||||||
if (session:ready()) then
|
if (session:ready()) then
|
||||||
sql = "select uuid from channels where presence_id = '"..extension.."@"..domain_name.."' ";
|
local sql = "select uuid from channels where presence_id = :presence_id ";
|
||||||
freeswitch.consoleLog("NOTICE", "[eavesdrop] sql "..sql.."\n");
|
local params = {presence_id = extension.."@"..domain_name};
|
||||||
dbh:query(sql, function(result)
|
if (debug["sql"]) then
|
||||||
|
freeswitch.consoleLog("notice", "[eavesdrop] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||||
|
end
|
||||||
|
dbh:query(sql, params, function(result)
|
||||||
for key, val in pairs(result) do
|
for key, val in pairs(result) do
|
||||||
freeswitch.consoleLog("NOTICE", "[eavesdrop] result "..key.." "..val.."\n");
|
freeswitch.consoleLog("NOTICE", "[eavesdrop] result "..key.." "..val.."\n");
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue