mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Change. library loads only needed files. (#2987)
This commit is contained in:
committed by
FusionPBX
parent
38002a8cb4
commit
eb72f3d5ce
@@ -31,16 +31,13 @@
|
|||||||
--include config.lua
|
--include config.lua
|
||||||
require "resources.functions.config";
|
require "resources.functions.config";
|
||||||
|
|
||||||
|
--create logger object
|
||||||
|
log = require "resources.functions.log".call_flow
|
||||||
|
|
||||||
--additional includes
|
--additional includes
|
||||||
local presence_in = require "resources.functions.presence_in"
|
local presence_in = require "resources.functions.presence_in"
|
||||||
local Database = require "resources.functions.database"
|
local Database = require "resources.functions.database"
|
||||||
local Settings = require "resources.functions.lazy_settings"
|
local play_file = require "resources.functions.play_file"
|
||||||
file = require "resources.functions.file"
|
|
||||||
log = require "resources.functions.log".call_flow
|
|
||||||
require "resources.functions.basename"
|
|
||||||
require "resources.functions.is_absolute_path"
|
|
||||||
require "resources.functions.find_file"
|
|
||||||
require "resources.functions.play_file"
|
|
||||||
|
|
||||||
--include json library
|
--include json library
|
||||||
local json
|
local json
|
||||||
@@ -52,19 +49,16 @@
|
|||||||
local dbh = Database.new('system');
|
local dbh = Database.new('system');
|
||||||
|
|
||||||
--get the variables
|
--get the variables
|
||||||
if (session:ready()) then
|
if not session:ready() then return end
|
||||||
domain_name = session:getVariable("domain_name");
|
|
||||||
domain_uuid = session:getVariable("domain_uuid");
|
|
||||||
call_flow_uuid = session:getVariable("call_flow_uuid");
|
|
||||||
sounds_dir = session:getVariable("sounds_dir");
|
|
||||||
feature_code = session:getVariable("feature_code");
|
|
||||||
end
|
|
||||||
|
|
||||||
--set the sounds path for the language, dialect and voice
|
local domain_name = session:getVariable("domain_name");
|
||||||
if (session:ready()) then
|
local domain_uuid = session:getVariable("domain_uuid");
|
||||||
local default_language = session:getVariable("default_language") or 'en';
|
local call_flow_uuid = session:getVariable("call_flow_uuid");
|
||||||
local default_dialect = session:getVariable("default_dialect") or 'us';
|
local feature_code = session:getVariable("feature_code");
|
||||||
local default_voice = session:getVariable("default_voice") or 'callie';
|
|
||||||
|
if not call_flow_uuid then
|
||||||
|
log.warning('Can not get call flow uuid')
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
--get the call flow details
|
--get the call flow details
|
||||||
@@ -179,6 +173,7 @@
|
|||||||
if (session:ready()) then
|
if (session:ready()) then
|
||||||
session:execute(app, data);
|
session:execute(app, data);
|
||||||
end
|
end
|
||||||
|
|
||||||
--timeout application
|
--timeout application
|
||||||
--if (not session:answered()) then
|
--if (not session:answered()) then
|
||||||
-- session:execute(ring_group_timeout_app, ring_group_timeout_data);
|
-- session:execute(ring_group_timeout_app, ring_group_timeout_data);
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
function basename(file_name)
|
function basename(file_name)
|
||||||
return (string.match(file_name, "([^/]+)$"))
|
return (string.match(file_name, "([^/]+)$"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return basename
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
pcall(require, "resources.functions.base64")
|
pcall(require, "resources.functions.base64")
|
||||||
|
|
||||||
-- load logger for file library
|
-- load logger for file library
|
||||||
local log = require "resources.functions.log".file
|
local log = log or require "resources.functions.log"[app_name or 'file']
|
||||||
|
|
||||||
local base64 = base64
|
local base64 = base64
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
|
local log = log or require "resources.functions.log"[app_name or 'find_file']
|
||||||
|
|
||||||
|
local file = require "resources.functions.file"
|
||||||
|
local Settings = require "resources.functions.lazy_settings"
|
||||||
|
local basename = require "resources.functions.basename"
|
||||||
|
local is_absolute_path = require "resources.functions.is_absolute_path"
|
||||||
|
|
||||||
function find_file(dbh, domain_name, domain_uuid, file_name)
|
function find_file(dbh, domain_name, domain_uuid, file_name)
|
||||||
|
|
||||||
-- if we specify e.g. full path
|
-- if we specify e.g. full path
|
||||||
if (is_absolute_path(file_name) and file.exists(file_name)) then
|
if (is_absolute_path(file_name) and file.exists(file_name)) then
|
||||||
log.debugf('found file `%s` in file system', file_name)
|
log.debugf('found file `%s` in file system', file_name)
|
||||||
@@ -43,14 +48,16 @@ function find_file(dbh, domain_name, domain_uuid, file_name)
|
|||||||
if not found then
|
if not found then
|
||||||
local sounds_dir
|
local sounds_dir
|
||||||
if session then
|
if session then
|
||||||
-- Implemented based on stream.lua. But seems it never works.
|
if session:ready() then
|
||||||
-- because if we have file like `digits/1.wav` but full_path is `sounds_dir/digits/XXXX/1.wav`
|
-- Implemented based on stream.lua. But seems it never works.
|
||||||
sounds_dir = session:getVariable("sounds_dir")
|
-- because if we have file like `digits/1.wav` but full_path is `sounds_dir/digits/XXXX/1.wav`
|
||||||
local default_language = session:getVariable("default_language") or 'en'
|
sounds_dir = session:getVariable("sounds_dir")
|
||||||
local default_dialect = session:getVariable("default_dialect") or 'us'
|
local default_language = session:getVariable("default_language") or 'en'
|
||||||
local default_voice = session:getVariable("default_voice") or 'callie'
|
local default_dialect = session:getVariable("default_dialect") or 'us'
|
||||||
|
local default_voice = session:getVariable("default_voice") or 'callie'
|
||||||
|
|
||||||
sounds_dir = sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice
|
sounds_dir = sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice
|
||||||
|
end
|
||||||
else
|
else
|
||||||
--! @todo implement for not session call.
|
--! @todo implement for not session call.
|
||||||
end
|
end
|
||||||
@@ -70,3 +77,5 @@ function find_file(dbh, domain_name, domain_uuid, file_name)
|
|||||||
|
|
||||||
return file_name, is_base64
|
return file_name, is_base64
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return find_file
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
function is_absolute_path(file_name)
|
function is_absolute_path(file_name)
|
||||||
return string.sub(file_name, 1, 1) == '/' or string.sub(file_name, 2, 1) == ':'
|
return string.sub(file_name, 1, 1) == '/' or string.sub(file_name, 2, 1) == ':'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return is_absolute_path
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
local log = log or require "resources.functions.log"[app_name or 'play_file']
|
||||||
|
local find_file = require "resources.functions.find_file"
|
||||||
|
|
||||||
function play_file(dbh, domain_name, domain_uuid, file_name)
|
function play_file(dbh, domain_name, domain_uuid, file_name)
|
||||||
local full_path, is_base64 = find_file(dbh, domain_name, domain_uuid, file_name)
|
local full_path, is_base64 = find_file(dbh, domain_name, domain_uuid, file_name)
|
||||||
if not full_path then
|
if not full_path then
|
||||||
@@ -8,3 +11,5 @@ function play_file(dbh, domain_name, domain_uuid, file_name)
|
|||||||
end
|
end
|
||||||
session:execute("playback", full_path);
|
session:execute("playback", full_path);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return play_file
|
||||||
Reference in New Issue
Block a user