Update recordings.lua
This commit is contained in:
parent
eb7b589ccc
commit
b8e0ccb2c2
|
|
@ -36,9 +36,16 @@
|
||||||
--include config.lua
|
--include config.lua
|
||||||
require "resources.functions.config";
|
require "resources.functions.config";
|
||||||
|
|
||||||
--connect to the database
|
--add functions
|
||||||
|
require "resources.functions.mkdir";
|
||||||
|
require "resources.functions.explode";
|
||||||
|
|
||||||
|
--load libraries
|
||||||
local Database = require "resources.functions.database";
|
local Database = require "resources.functions.database";
|
||||||
dbh = Database.new('system');
|
local Settings = require "resources.functions.lazy_settings";
|
||||||
|
|
||||||
|
--setup the database connection
|
||||||
|
local db = dbh or Database.new('system');
|
||||||
|
|
||||||
--include json library
|
--include json library
|
||||||
local json
|
local json
|
||||||
|
|
@ -49,42 +56,35 @@
|
||||||
--get the domain_uuid
|
--get the domain_uuid
|
||||||
domain_uuid = session:getVariable("domain_uuid");
|
domain_uuid = session:getVariable("domain_uuid");
|
||||||
|
|
||||||
--add functions
|
|
||||||
require "resources.functions.mkdir";
|
|
||||||
require "resources.functions.explode";
|
|
||||||
|
|
||||||
--initialize the recordings
|
--initialize the recordings
|
||||||
api = freeswitch.API();
|
api = freeswitch.API();
|
||||||
|
|
||||||
--settings
|
--load libraries
|
||||||
require "resources.functions.settings";
|
local Database = require "resources.functions.database";
|
||||||
settings = settings(domain_uuid);
|
local Settings = require "resources.functions.lazy_settings";
|
||||||
storage_type = "";
|
|
||||||
storage_path = "";
|
--setup the database connection
|
||||||
if (settings['recordings'] ~= nil) then
|
local db = dbh or Database.new('system');
|
||||||
if (settings['recordings']['storage_type'] ~= nil) then
|
|
||||||
if (settings['recordings']['storage_type']['text'] ~= nil) then
|
--get the recordings settings
|
||||||
storage_type = settings['recordings']['storage_type']['text'];
|
local settings = Settings.new(db, domain_name, domain_uuid);
|
||||||
end
|
|
||||||
end
|
--set the storage type and path
|
||||||
if (settings['recordings']['storage_path'] ~= nil) then
|
storage_type = settings:get('recordings', 'storage_type', 'text') or '';
|
||||||
if (settings['recordings']['storage_path']['text'] ~= nil) then
|
storage_path = settings:get('recordings', 'storage_path', 'text') or '';
|
||||||
storage_path = settings['recordings']['storage_path']['text'];
|
if (storage_path ~= '') then
|
||||||
storage_path = storage_path:gsub("${domain_name}", session:getVariable("domain_name"));
|
storage_path = storage_path:gsub("${domain_name}", session:getVariable("domain_name"));
|
||||||
storage_path = storage_path:gsub("${domain_uuid}", domain_uuid);
|
storage_path = storage_path:gsub("${domain_uuid}", domain_uuid);
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if (not temp_dir) or (#temp_dir == 0) then
|
|
||||||
if (settings['server'] ~= nil) then
|
|
||||||
if (settings['server']['temp'] ~= nil) then
|
|
||||||
if (settings['server']['temp']['dir'] ~= nil) then
|
|
||||||
temp_dir = settings['server']['temp']['dir'];
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--set the recordings variables
|
||||||
|
local recording_max_length = settings:get('recordings', 'recording_max_length', 'numeric') or 90;
|
||||||
|
local recording_silence_threshold = settings:get('recordings', 'recording_silence_threshold', 'numeric') or 200;
|
||||||
|
local recording_silence_seconds = settings:get('recordings', 'recording_silence_seconds', 'numeric') or 3;
|
||||||
|
|
||||||
|
--set the temp directory
|
||||||
|
temp_dir = settings:get('server', 'temp', 'dir') or nil;
|
||||||
|
|
||||||
--dtmf call back function detects the "#" and ends the call
|
--dtmf call back function detects the "#" and ends the call
|
||||||
function onInput(s, type, obj)
|
function onInput(s, type, obj)
|
||||||
if (type == "dtmf" and obj['digit'] == '#') then
|
if (type == "dtmf" and obj['digit'] == '#') then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue