mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Recordings - Enable Default/Domain/User setting to control filename prefix and password.
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
--add functions
|
||||
require "resources.functions.mkdir";
|
||||
require "resources.functions.explode";
|
||||
local cache = require "resources.functions.cache"
|
||||
|
||||
--setup the database connection
|
||||
local Database = require "resources.functions.database";
|
||||
@@ -53,22 +54,29 @@
|
||||
--get the domain_uuid
|
||||
if (session:ready()) then
|
||||
domain_uuid = session:getVariable("domain_uuid");
|
||||
user_uuid = session:getVariable("user_uuid");
|
||||
end
|
||||
|
||||
--initialize the recordings
|
||||
api = freeswitch.API();
|
||||
|
||||
--clear cached prefix and password, refreshed from database settings
|
||||
if cache.support() then
|
||||
cache.del("setting::recordings.recording_prefix.text")
|
||||
cache.del("setting::recordings.recording_password.numeric")
|
||||
end
|
||||
|
||||
--load lazy settings library
|
||||
local Settings = require "resources.functions.lazy_settings";
|
||||
|
||||
--get the recordings settings
|
||||
local settings = Settings.new(db, domain_name, domain_uuid);
|
||||
local settings = Settings.new(db, domain_name, domain_uuid, user_uuid);
|
||||
|
||||
--set the storage type and path
|
||||
storage_type = settings:get('recordings', 'storage_type', 'text') or '';
|
||||
storage_path = settings:get('recordings', 'storage_path', 'text') or '';
|
||||
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);
|
||||
end
|
||||
|
||||
@@ -98,7 +106,7 @@
|
||||
if (not default_dialect) then default_dialect = 'us'; end
|
||||
if (not default_voice) then default_voice = 'callie'; end
|
||||
recording_id = session:getVariable("recording_id");
|
||||
recording_prefix = session:getVariable("recording_prefix");
|
||||
recording_prefix = settings:get('recordings', 'recording_prefix', 'text') or session:getVariable("recording_prefix");
|
||||
recording_name = session:getVariable("recording_name");
|
||||
record_ext = session:getVariable("record_ext");
|
||||
domain_name = session:getVariable("domain_name");
|
||||
@@ -294,7 +302,7 @@ if (session:ready()) then
|
||||
session:answer();
|
||||
|
||||
--get the dialplan variables and set them as local variables
|
||||
pin_number = session:getVariable("pin_number");
|
||||
pin_number = settings:get('recordings', 'recording_password', 'numeric') or session:getVariable("pin_number");
|
||||
sounds_dir = session:getVariable("sounds_dir");
|
||||
domain_name = session:getVariable("domain_name");
|
||||
domain_uuid = session:getVariable("domain_uuid");
|
||||
|
||||
@@ -49,12 +49,13 @@ local function append_setting(array, category, subcategory, name, value)
|
||||
end
|
||||
end
|
||||
|
||||
function Settings.new(db, domain_name, domain_uuid)
|
||||
function Settings.new(db, domain_name, domain_uuid, user_uuid)
|
||||
local self = setmetatable({}, Settings)
|
||||
self._array = {}
|
||||
self._db = db
|
||||
self._domain_name = domain_name
|
||||
self._domain_uuid = domain_uuid
|
||||
self._user_uuid = user_uuid
|
||||
self._use_cache = not cache.settings
|
||||
|
||||
return self
|
||||
@@ -93,6 +94,7 @@ function Settings:get(category, subcategory, name)
|
||||
end
|
||||
|
||||
function Settings:_load(category, subcategory, name)
|
||||
local user_uuid = self._user_uuid
|
||||
local domain_uuid = self._domain_uuid
|
||||
local db = self._db
|
||||
if type(self._db) == 'string' then
|
||||
@@ -101,8 +103,37 @@ function Settings:_load(category, subcategory, name)
|
||||
|
||||
local found = false
|
||||
|
||||
--get the user settings
|
||||
if user_uuid then
|
||||
local sql = "SELECT user_setting_uuid,user_setting_category,user_setting_subcategory,user_setting_name,user_setting_value "
|
||||
sql = sql .. "FROM v_user_settings ";
|
||||
sql = sql .. "WHERE user_uuid = :user_uuid ";
|
||||
sql = sql .. "AND user_setting_enabled = 'true' ";
|
||||
sql = sql .. "AND user_setting_category = :category ";
|
||||
sql = sql .. "AND user_setting_subcategory = :subcategory ";
|
||||
sql = sql .. "AND user_setting_name = :name ";
|
||||
sql = sql .. "AND user_setting_value is not null ";
|
||||
sql = sql .. "ORDER BY user_setting_category, user_setting_subcategory ASC ";
|
||||
local params = {
|
||||
user_uuid = user_uuid,
|
||||
category = category,
|
||||
subcategory = subcategory,
|
||||
name = name,
|
||||
};
|
||||
|
||||
db:query(sql, params, function(row)
|
||||
found = true;
|
||||
self:set(
|
||||
row.user_setting_category,
|
||||
row.user_setting_subcategory,
|
||||
row.user_setting_name,
|
||||
row.user_setting_value
|
||||
)
|
||||
end)
|
||||
end
|
||||
|
||||
--get the domain settings
|
||||
if domain_uuid then
|
||||
if not found and domain_uuid then
|
||||
local sql = "SELECT domain_setting_uuid,domain_setting_category,domain_setting_subcategory,domain_setting_name,domain_setting_value "
|
||||
sql = sql .. "FROM v_domain_settings ";
|
||||
sql = sql .. "WHERE domain_uuid = :domain_uuid ";
|
||||
|
||||
Reference in New Issue
Block a user