Update recordings.lua

This commit is contained in:
FusionPBX
2019-09-25 16:46:52 -06:00
committed by GitHub
parent 2d84d8b15c
commit 9535eea24b
+16 -14
View File
@@ -40,11 +40,8 @@
require "resources.functions.mkdir"; require "resources.functions.mkdir";
require "resources.functions.explode"; require "resources.functions.explode";
--load libraries
local Database = require "resources.functions.database";
local Settings = require "resources.functions.lazy_settings";
--setup the database connection --setup the database connection
local Database = require "resources.functions.database";
local db = dbh or Database.new('system'); local db = dbh or Database.new('system');
--include json library --include json library
@@ -54,18 +51,16 @@
end end
--get the domain_uuid --get the domain_uuid
domain_uuid = session:getVariable("domain_uuid"); if (session:ready()) then
domain_uuid = session:getVariable("domain_uuid");
end
--initialize the recordings --initialize the recordings
api = freeswitch.API(); api = freeswitch.API();
--load libraries --load lazy settings library
local Database = require "resources.functions.database";
local Settings = require "resources.functions.lazy_settings"; local Settings = require "resources.functions.lazy_settings";
--setup the database connection
local db = dbh or Database.new('system');
--get the recordings settings --get the recordings settings
local settings = Settings.new(db, domain_name, domain_uuid); local settings = Settings.new(db, domain_name, domain_uuid);
@@ -166,19 +161,23 @@
session:execute("record", "'"..recordings_dir.."/"..recording_name.."' "..time_limit_secs.." "..silence_thresh.." "..silence_hits); session:execute("record", "'"..recordings_dir.."/"..recording_name.."' "..time_limit_secs.." "..silence_thresh.." "..silence_hits);
end end
--setup the database connection
local Database = require "resources.functions.database";
local db = dbh or Database.new('system');
--get the description of the previous recording --get the description of the previous recording
sql = "SELECT recording_description FROM v_recordings "; sql = "SELECT recording_description 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 ";
sql = sql .. "limit 1"; sql = sql .. "limit 1";
local params = {domain_uuid = domain_uuid, recording_name = recording_name}; local params = {domain_uuid = domain_uuid, recording_name = recording_name};
local recording_description = dbh:first_value(sql, params) or '' local recording_description = db:first_value(sql, params) or ''
--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, {domain_uuid = domain_uuid, recording_name = recording_name}); db: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");
@@ -227,7 +226,10 @@
dbh:query(sql, params); dbh:query(sql, params);
dbh:release(); dbh:release();
else else
dbh:query(sql, params); --setup the database connection
local Database = require "resources.functions.database";
local db = dbh or Database.new('system');
db:query(sql, params);
end end
--preview the recording --preview the recording
@@ -279,7 +281,7 @@
end end
end end
if ( session:ready() ) then if (session:ready()) then
session:answer(); session:answer();
--get the dialplan variables and set them as local variables --get the dialplan variables and set them as local variables