summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rw-r--r--misc/freeswitch/scripts/dialplan/dialplan.lua8
-rw-r--r--misc/freeswitch/scripts/dialplan/router.lua11
2 files changed, 9 insertions, 10 deletions
diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua
index e90354c..0407485 100644
--- a/misc/freeswitch/scripts/dialplan/dialplan.lua
+++ b/misc/freeswitch/scripts/dialplan/dialplan.lua
@@ -624,7 +624,7 @@ function Dialplan.callthrough(self, destination)
end
require 'dialplan.router'
- local route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller }:route_run('prerouting', destination_number, true);
+ local route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('prerouting', destination_number, true);
if route and route.destination_number then
destination_number = route.destination_number;
@@ -773,7 +773,7 @@ function Dialplan.switch(self, destination)
destination.callee_id_name = nil;
require 'dialplan.router'
- local routes = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller }:route_run('outbound', destination.number);
+ local routes = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('outbound', destination.number);
if not routes or #routes == 0 then
self.log:notice('SWITCH - no route - number: ', destination.number);
@@ -878,7 +878,7 @@ function Dialplan.run(self, destination)
self.caller.destination_number = self.caller:to_s(self.caller.gateway.settings.number_source);
end
- route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller }:route_run('inbound', self.caller.destination_number, true);
+ route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('inbound', self.caller.destination_number, true);
if route then
local ignore_keys = {
id = true,
@@ -898,7 +898,7 @@ function Dialplan.run(self, destination)
self.log:notice('INBOUND - no route');
end
else
- route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller }:route_run('prerouting', self.caller.destination_number, true);
+ route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = self.caller, variables = self.caller }:route_run('prerouting', self.caller.destination_number, true);
if route then
local ignore_keys = {
id = true,
diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua
index 6c5b9f1..5f427ac 100644
--- a/misc/freeswitch/scripts/dialplan/router.lua
+++ b/misc/freeswitch/scripts/dialplan/router.lua
@@ -52,21 +52,20 @@ function Router.read_table(self, table_name)
end
-function Router.expand_variables(self, line)
- return (line:gsub('{([%a%d_]+)}', function(captured)
- return variables[captured] or '';
+function Router.expand_variables(self, line, variables)
+ return (line:gsub('{([%a%d%._]+)}', function(captured)
+ return common.str.try(variables, captured) or '';
end))
end
function Router.element_match(self, pattern, search_string, replacement)
- local variables_list = {};
local success, result = pcall(string.find, search_string, pattern);
if not success then
self.log:error('ELEMENT_MATCH - table error - pattern: ', pattern, ', search_string: ', search_string);
elseif result then
- return true, search_string:gsub(pattern, self:expand_variables(replacement, variables_list));
+ return true, search_string:gsub(pattern, self:expand_variables(replacement, self.variables));
end
return false;
@@ -109,7 +108,7 @@ function Router.route_match(self, route)
if element.action ~= 'none' then
if common.str.blank(element.var_in) or common.str.blank(element.pattern) and element.action == 'set' then
result = true;
- replacement = element.replacement;
+ replacement = self:expand_variables(element.replacement, self.variables);
else
local command, variable_name = common.str.partition(element.var_in, ':');