Add. Use params in recordings.lua (#2121)
This commit is contained in:
parent
83de1e8dd0
commit
2db938c860
|
|
@ -37,9 +37,15 @@
|
||||||
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_handle('system');
|
||||||
|
|
||||||
|
--include json library
|
||||||
|
local json
|
||||||
|
if (debug["sql"]) then
|
||||||
|
json = require "resources.functions.lunajson"
|
||||||
|
end
|
||||||
|
|
||||||
--get the domain_uuid
|
--get the domain_uuid
|
||||||
domain_uuid = session:getVariable("domain_uuid");
|
domain_uuid = session:getVariable("domain_uuid");
|
||||||
|
|
||||||
|
|
@ -152,9 +158,9 @@
|
||||||
|
|
||||||
--delete the previous recording
|
--delete the previous recording
|
||||||
sql = "delete from v_recordings ";
|
sql = "delete from v_recordings ";
|
||||||
sql = sql .. "where domain_uuid = '".. domain_uuid .. "' ";
|
sql = sql .. "where domain_uuid = :domain_uuid ";
|
||||||
sql = sql .. "and recording_filename = '".. recording_name .."'";
|
sql = sql .. "and recording_filename = :recording_name";
|
||||||
dbh:query(sql);
|
dbh:query(sql, {domain_uuid = domain_uuid, recording_name = recording_name});
|
||||||
|
|
||||||
--get a new uuid
|
--get a new uuid
|
||||||
recording_uuid = api:execute("create_uuid");
|
recording_uuid = api:execute("create_uuid");
|
||||||
|
|
@ -173,25 +179,34 @@
|
||||||
table.insert(array, ") ");
|
table.insert(array, ") ");
|
||||||
table.insert(array, "VALUES ");
|
table.insert(array, "VALUES ");
|
||||||
table.insert(array, "( ");
|
table.insert(array, "( ");
|
||||||
table.insert(array, "'"..recording_uuid.."', ");
|
table.insert(array, ":recording_uuid, ");
|
||||||
table.insert(array, "'"..domain_uuid.."', ");
|
table.insert(array, ":domain_uuid, ");
|
||||||
table.insert(array, "'"..recording_name.."', ");
|
table.insert(array, ":recording_name, ");
|
||||||
if (storage_type == "base64") then
|
if (storage_type == "base64") then
|
||||||
table.insert(array, "'"..recording_base64.."', ");
|
table.insert(array, ":recording_base64, ");
|
||||||
end
|
end
|
||||||
table.insert(array, "'"..recording_name.."' ");
|
table.insert(array, ":recording_name ");
|
||||||
table.insert(array, ") ");
|
table.insert(array, ") ");
|
||||||
sql = table.concat(array, "\n");
|
sql = table.concat(array, "\n");
|
||||||
|
|
||||||
|
local params = {
|
||||||
|
recording_uuid = recording_uuid;
|
||||||
|
domain_uuid = domain_uuid;
|
||||||
|
recording_name = recording_name;
|
||||||
|
recording_base64 = recording_base64;
|
||||||
|
};
|
||||||
|
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("notice", "[recording] SQL: " .. sql .. "\n");
|
freeswitch.consoleLog("notice", "[recording] SQL: " .. sql .. "; params: " .. json.encode(params) .. "\n");
|
||||||
end
|
end
|
||||||
|
|
||||||
if (storage_type == "base64") then
|
if (storage_type == "base64") then
|
||||||
local Database = require "resources.functions.database"
|
local Database = require "resources.functions.database"
|
||||||
local dbh = Database.new('system', 'base64');
|
local dbh = Database.new('system', 'base64');
|
||||||
dbh:query(sql);
|
dbh:query(sql, params);
|
||||||
dbh:release();
|
dbh:release();
|
||||||
else
|
else
|
||||||
dbh:query(sql);
|
dbh:query(sql, params);
|
||||||
end
|
end
|
||||||
|
|
||||||
--preview the recording
|
--preview the recording
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue