diff options
author | spag <spag@golwen.net> | 2013-01-20 16:17:09 +0100 |
---|---|---|
committer | spag <spag@golwen.net> | 2013-01-20 16:17:09 +0100 |
commit | e840f0b4d7bab10b53174b607ed60e1bce450321 (patch) | |
tree | b843ceaa9ef672be4bbbba1e3da241489e9e21ec /misc/freeswitch/scripts | |
parent | 79e4b0b95336d568b5f65bcd793995a7d0d4ee50 (diff) |
routing in hunt group class
Diffstat (limited to 'misc/freeswitch/scripts')
-rw-r--r-- | misc/freeswitch/scripts/dialplan/hunt_group.lua | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/misc/freeswitch/scripts/dialplan/hunt_group.lua b/misc/freeswitch/scripts/dialplan/hunt_group.lua index 44c2bb8..07f403e 100644 --- a/misc/freeswitch/scripts/dialplan/hunt_group.lua +++ b/misc/freeswitch/scripts/dialplan/hunt_group.lua @@ -98,21 +98,35 @@ function HuntGroup.run(self, dialplan_object, caller, destination) self.log:info('HUNTGROUP ', self.record.id, ' - name: ', self.record.name, ', strategy: ', self.record.strategy,', members: ', #hunt_group_members); + local save_destination = caller.destination; + local destinations = {} for index, hunt_group_member in ipairs(hunt_group_members) do local destination = dialplan_object:destination_new{ number = hunt_group_member.number }; if destination.type == 'unknown' then - require 'dialplan.route' - local routes = dialplan.route.Route:new{ log = self.log, database = self.database, routing_table = dialplan_object.routes }:outbound(caller, destination.number); - if routes and #routes > 0 then - destination.callee_id_number = destination.number; - destination.callee_id_name = nil; - local route = routes[1]; - destination.gateway = route.endpoint; - destination.type = route.class; - destination.number = route.value; - destination.caller_id_number = route.caller_id_number; - destination.caller_id_name = route.caller_id_name; + self.log:notice('HG_DESTINATION - number: ', destination.number, ', hunt_group_member.number: ', hunt_group_member.number); + + + caller.destination_number = destination.number; + + require 'dialplan.router' + local route = dialplan.router.Router:new{ log = self.log, database = self.database, caller = caller, variables = caller }:route_run('outbound', true); + + if route then + destination = dialplan_object:destination_new{ ['type'] = route.type, id = route.id, number = route.destination_number } + + local ignore_keys = { + id = true, + ['type'] = true, + channel_variables = true, + }; + + for key, value in pairs(route) do + if not ignore_keys[key] then + destination[key] = value; + end + end + table.insert(destinations, destination); end else @@ -120,6 +134,9 @@ function HuntGroup.run(self, dialplan_object, caller, destination) end end + caller.destination = save_destination; + caller.destination_number = save_destination.number; + local forwarding_destination = nil; if caller.forwarding_service == 'assistant' and caller.auth_account then forwarding_destination = dialplan_object:destination_new{ type = caller.auth_account.class, id = caller.auth_account.id, number = forwarding_number } |