diff options
Diffstat (limited to 'misc/freeswitch/scripts/dialplan')
-rw-r--r-- | misc/freeswitch/scripts/dialplan/acd.lua | 2 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/cdr.lua | 2 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/dialplan.lua | 29 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/fax.lua | 2 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/geo_number.lua | 2 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/hunt_group.lua | 2 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/phone_book.lua | 2 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/presence.lua | 2 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/route.lua | 2 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/router.lua | 11 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/session.lua | 5 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/sip_call.lua | 2 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/tenant.lua | 2 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/user.lua | 2 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/voicemail.lua | 2 |
15 files changed, 36 insertions, 33 deletions
diff --git a/misc/freeswitch/scripts/dialplan/acd.lua b/misc/freeswitch/scripts/dialplan/acd.lua index 563d836..f4b298e 100644 --- a/misc/freeswitch/scripts/dialplan/acd.lua +++ b/misc/freeswitch/scripts/dialplan/acd.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: acd class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/cdr.lua b/misc/freeswitch/scripts/dialplan/cdr.lua index 55a7889..d0fdede 100644 --- a/misc/freeswitch/scripts/dialplan/cdr.lua +++ b/misc/freeswitch/scripts/dialplan/cdr.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: cdr class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index e90354c..3fcb2bd 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: dialplan class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) @@ -7,7 +7,6 @@ module(...,package.seeall) Dialplan = {} -- local constants -local CONFIG_FILE_NAME = '/opt/freeswitch/scripts/ini/dialplan.ini'; local DIAL_TIMEOUT = 120; local MAX_LOOPS = 20; local DIALPLAN_FUNCTION_PATTERN = '^f[_%-].*'; @@ -235,19 +234,21 @@ end function Dialplan.retrieve_caller_data(self) - self.caller.caller_phone_numbers_hash = {} - require 'common.str' - local dialed_sip_user = self.caller:to_s('dialed_user'); + self.caller.caller_phone_numbers_hash = {} -- TODO: Set auth_account on transfer initiated by calling party - if not common.str.blank(dialed_sip_user) then - self.caller.auth_account = self:object_find('sipaccount', self.caller:to_s('dialed_domain'), dialed_sip_user); - self.caller:set_auth_account(self.caller.auth_account); + if not common.str.blank(self.caller.dialed_sip_user) then + self.caller.auth_account = self:object_find('sipaccount', self.caller.dialed_domain, dialed_sip_user); + if self.caller.set_auth_account then + self.caller:set_auth_account(self.caller.auth_account); + end elseif not common.str.blank(self.caller.auth_account_type) and not common.str.blank(self.caller.auth_account_uuid) then self.caller.auth_account = self:object_find(self.caller.auth_account_type, self.caller.auth_account_uuid); - self.caller:set_auth_account(self.caller.auth_account); + if self.caller.set_auth_account then + self.caller:set_auth_account(self.caller.auth_account); + end end if self.caller.auth_account then @@ -276,7 +277,7 @@ function Dialplan.retrieve_caller_data(self) self.log:error('CALLER_DATA - caller owner not found'); end - if not self.caller.clir then + if not self.caller.clir and self.caller.set_caller_id then self.caller:set_caller_id(self.caller.caller_phone_numbers[1], self.caller.account.record.caller_name or self.caller.account.record.name); end else @@ -624,7 +625,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 +774,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 +879,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 +899,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/fax.lua b/misc/freeswitch/scripts/dialplan/fax.lua index 2a40620..aa29ff6 100644 --- a/misc/freeswitch/scripts/dialplan/fax.lua +++ b/misc/freeswitch/scripts/dialplan/fax.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: fax class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/geo_number.lua b/misc/freeswitch/scripts/dialplan/geo_number.lua index 06bfd62..76cc01b 100644 --- a/misc/freeswitch/scripts/dialplan/geo_number.lua +++ b/misc/freeswitch/scripts/dialplan/geo_number.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: geonumber class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/hunt_group.lua b/misc/freeswitch/scripts/dialplan/hunt_group.lua index 87f86f1..44c2bb8 100644 --- a/misc/freeswitch/scripts/dialplan/hunt_group.lua +++ b/misc/freeswitch/scripts/dialplan/hunt_group.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: hunt group class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/phone_book.lua b/misc/freeswitch/scripts/dialplan/phone_book.lua index 089f115..6653789 100644 --- a/misc/freeswitch/scripts/dialplan/phone_book.lua +++ b/misc/freeswitch/scripts/dialplan/phone_book.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: phone book class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/presence.lua b/misc/freeswitch/scripts/dialplan/presence.lua index 234b908..0f63ce9 100644 --- a/misc/freeswitch/scripts/dialplan/presence.lua +++ b/misc/freeswitch/scripts/dialplan/presence.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: presence class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/route.lua b/misc/freeswitch/scripts/dialplan/route.lua index 2243cbe..a12b5f9 100644 --- a/misc/freeswitch/scripts/dialplan/route.lua +++ b/misc/freeswitch/scripts/dialplan/route.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: routing class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) 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, ':'); diff --git a/misc/freeswitch/scripts/dialplan/session.lua b/misc/freeswitch/scripts/dialplan/session.lua index 20fef88..7de85ca 100644 --- a/misc/freeswitch/scripts/dialplan/session.lua +++ b/misc/freeswitch/scripts/dialplan/session.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: caller session class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) @@ -43,6 +43,9 @@ function Session.init_channel_variables(self) self.from_gateway = true; end + self.dialed_sip_user = self:to_s('dialed_user'); + self.dialed_domain = self:to_s('dialed_domain'); + self.account_uuid = self:to_s('gs_account_uuid'); self.account_type = self:to_s('gs_account_type'); self.sip_contact_host = self:to_s('sip_contact_host'); diff --git a/misc/freeswitch/scripts/dialplan/sip_call.lua b/misc/freeswitch/scripts/dialplan/sip_call.lua index 0b799e5..3f56753 100644 --- a/misc/freeswitch/scripts/dialplan/sip_call.lua +++ b/misc/freeswitch/scripts/dialplan/sip_call.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: sip call class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall); diff --git a/misc/freeswitch/scripts/dialplan/tenant.lua b/misc/freeswitch/scripts/dialplan/tenant.lua index 8d6436c..904609e 100644 --- a/misc/freeswitch/scripts/dialplan/tenant.lua +++ b/misc/freeswitch/scripts/dialplan/tenant.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: user class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/user.lua b/misc/freeswitch/scripts/dialplan/user.lua index 0a2e0dd..b536600 100644 --- a/misc/freeswitch/scripts/dialplan/user.lua +++ b/misc/freeswitch/scripts/dialplan/user.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: user class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) diff --git a/misc/freeswitch/scripts/dialplan/voicemail.lua b/misc/freeswitch/scripts/dialplan/voicemail.lua index fe20128..5d79ba3 100644 --- a/misc/freeswitch/scripts/dialplan/voicemail.lua +++ b/misc/freeswitch/scripts/dialplan/voicemail.lua @@ -1,5 +1,5 @@ -- Gemeinschaft 5 module: voicemail class --- (c) AMOOMA GmbH 2012 +-- (c) AMOOMA GmbH 2012-2013 -- module(...,package.seeall) |