diff options
Diffstat (limited to 'misc')
-rw-r--r-- | misc/freeswitch/scripts/dialplan/dialplan.lua | 18 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/session.lua | 3 | ||||
-rw-r--r-- | misc/freeswitch/scripts/ini/routes.ini | 80 | ||||
-rw-r--r-- | misc/freeswitch/scripts/send_fax.lua | 48 |
4 files changed, 36 insertions, 113 deletions
diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 405a664..3fcb2bd 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -234,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 @@ -275,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 diff --git a/misc/freeswitch/scripts/dialplan/session.lua b/misc/freeswitch/scripts/dialplan/session.lua index 4029f9e..6cb670c 100644 --- a/misc/freeswitch/scripts/dialplan/session.lua +++ b/misc/freeswitch/scripts/dialplan/session.lua @@ -43,6 +43,9 @@ function Session.init_channel_variables(self) self.from_gateway = true; end + self.dialed_sip_user = self.caller:to_s('dialed_user'); + self.dialed_domain = self.caller: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/ini/routes.ini b/misc/freeswitch/scripts/ini/routes.ini deleted file mode 100644 index 535ba63..0000000 --- a/misc/freeswitch/scripts/ini/routes.ini +++ /dev/null @@ -1,80 +0,0 @@ -; Gemeinschaft 5 routing configuration file -; (c) AMOOMA GmbH 2012-2013 -; - -[general] - - -[prerouting] -^%*0%*$ , f-li -^%*0%*(%d+)#*$ , f-li-%1 -^%*0%*(%d+)%*(%d+)#*$ , f-li-%1-%2 -^#0#$ , f-lo -^%*5%*(%d+)#$ , f-acdmtg-0-%1 -^%*30#$ , f-clipon -^#30#$ , f-clipoff -^%*31#$ , f-cliroff -^#31#$ , f-cliron -^%*31#(%d+)$ , f-dcliroff-%1 -^#31#(%d+)$ , f-dcliron-%1 -^%*43#$ , f-cwaon -^#43#$ , f-cwaoff -^#002#$ , f-cfoff -^##002#$ , f-cfdel -^%*21#$ , f-cfu -^%*21%*(%d+)#$ , f-cfu-%1 -^%*%*21%*(%d+)#$ , f-cfu-%1 -^#21#$ , f-cfuoff -^##21#$ , f-cfudel -^%*61#$ , f-cfn -^%*61%*(%d+)#$ , f-cfn-%1 -^%*%*61%*(%d+)#$ , f-cfn-%1 -^%*61%*(%d+)%*(%d+)#$ , f-cfn-%1-%2 -^%*%*61%*(%d+)%*(%d+)#$ , f-cfn-%1-%2 -^#61#$ , f-cfnoff -^##61#$ , f-cfndel -^%*62#$ , f-cfo -^%*62%*(%d+)#$ , f-cfo-%1 -^%*%*62%*(%d+)#$ , f-cfo-%1 -^#62#$ , f-cfooff -^##62#$ , f-cfodel -^%*67#$ , f-cfb -^%*67%*(%d+)#$ , f-cfb-%1 -^%*%*67%*(%d+)#$ , f-cfb-%1 -^#67#$ , f-cfboff -^##67#$ , f-cfbdel -^%*66#$ , f-redial -^%*98$ , f-vmcheck -^%*98#$ , f-vmcheck -^%*98%*(%d+)#$ , f-vmcheck-%1 -^%*1337%*1%*1#$ , f-loaon -^%*1337%*1%*0#$ , f-loaoff - -^00(%d+)$ , +%1 -^0(%d+)$ , +49%1 - - -[outbound] -^%+(%d+)$ , class=gateway, endpoint=gateway1, group=users, %1 - - -[failover] -UNALLOCATED_NUMBER = true -NORMAL_TEMPORARY_FAILURE = true - - -[outbound_cid_number] - - -[outbound_cid_name] - - -[inbound] -^00(%d+)$ , +%1 -^0(%d+)$ , +49%1 - -[inbound_cid_number] -^00(%d+)$ , +%1 -^0(%d+)$ , +49%1 - -[inbound_cid_name] diff --git a/misc/freeswitch/scripts/send_fax.lua b/misc/freeswitch/scripts/send_fax.lua index a3de5f6..35460a3 100644 --- a/misc/freeswitch/scripts/send_fax.lua +++ b/misc/freeswitch/scripts/send_fax.lua @@ -80,36 +80,34 @@ local session = nil if phone_number then session = freeswitch.Session("[" .. table.concat(origination_variables, ",") .. "]loopback/" .. destination_number .. "/default"); else - local owner_class = common.str.downcase(fax_account.record.fax_accountable_type); - - local caller = {} - caller.caller_phone_numbers = phone_number_class:list_by_owner(fax_account.record.id, 'FaxAccount'); - caller.account = fax_account; - caller.auth_account = fax_account; - caller.caller_id_name = fax_account.record.station_id; - - if owner_class == 'user' then - require 'dialplan.user' - caller.auth_account.owner = dialplan.user.User:new{ log = log, database = database }:find_by_id(fax_account.record.fax_accountable_id); - if caller.auth_account.owner then - caller.auth_account.owner.groups = caller.auth_account.owner:list_groups(); - end - elseif owner_class == 'tenant' then - require 'dialplan.tenant' - caller.auth_account.owner = dialplan.tenant.Tenant:new{ log = log, database = database }:find_by_id(fax_account.record.fax_accountable_id); - end + local caller = { + destination_number = destination_number, + caller_id_name = fax_account.record.station_id, + account_type = 'faxaccount', + account_uuid = fax_account.uuid, + auth_account_type = 'faxaccount', + auth_account_uuid = fax_account.uuid, + } - require 'common.configuration_file' - local routing_table = common.configuration_file.get('/opt/freeswitch/scripts/ini/routes.ini'); - require 'dialplan.route' - local routes = dialplan.route.Route:new{ log = log, database = database, routing_table = routing_table }:outbound(caller, destination_number); + require 'dialplan.dialplan' + local dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = caller, database = database }; + local result = dialplan:retrieve_caller_data(); + + local dialplan_router = require('dialplan.router'); + local routes = dialplan_router.Router:new{ log = log, database = database, caller = caller, variables = caller }:route_run('outbound', destination_number); + + if not routes or #routes == 0 then + log:notice('SWITCH - no route - number: ', destination_number); + return { continue = false, code = 404, phrase = 'No route' } + end for index, route in ipairs(routes) do - log:info('FAX_SEND - ', route.class, '=', route.endpoint, ', number: ', route.value); - if route.class == 'gateway' then + log:info('FAX_SEND - ', route.type, '=', route.id, '/', route.gateway,', number: ', route.destination_number); + if route.type == 'gateway' then table.insert(origination_variables, "origination_caller_id_number='" .. (route.caller_id_number or caller.caller_phone_numbers[1]) .. "'"); table.insert(origination_variables, "origination_caller_id_name='" .. (route.caller_id_name or fax_account.record.station_id) .. "'"); - session = freeswitch.Session('[' .. table.concat(origination_variables, ',') .. ']sofia/gateway/' .. route.endpoint .. '/' .. route.value); + session = freeswitch.Session('[' .. table.concat(origination_variables, ',') .. ']sofia/gateway/' .. route.gateway .. '/' .. route.destination_number); + log:notice('SESSION: ', session); break; end end |