From 8170be475b351a4eb8844430ebdf8c96d8482fe3 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Sun, 27 Aug 2017 15:11:31 -0600 Subject: [PATCH] Update index.lua --- .../install/scripts/app/ring_groups/index.lua | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/resources/install/scripts/app/ring_groups/index.lua b/resources/install/scripts/app/ring_groups/index.lua index e034de33e6..0da22be47e 100644 --- a/resources/install/scripts/app/ring_groups/index.lua +++ b/resources/install/scripts/app/ring_groups/index.lua @@ -343,6 +343,28 @@ --add the row to the destinations array destinations[x] = row; end + --determine if the user is registered if not registered then lookup + cmd = "sofia_contact ".. row.destination_number .."@" ..leg_domain_name; + if (api:executeString(cmd) == "error/user_not_registered") then + cmd = "user_data ".. row.destination_number .."@" ..leg_domain_name.." var forward_user_not_registered_enabled"; + if (api:executeString(cmd) == "true") then + --get the new destination number + cmd = "user_data ".. row.destination_number .."@" ..leg_domain_name.." var forward_user_not_registered_destination"; + destination_number = api:executeString(cmd); + if (row.destination_number ~= nil) then + row.destination_number = destination_number; + end + + --check the new destination number for user_exists + cmd = "user_exists id ".. row.destination_number .." "..leg_domain_name; + user_exists = api:executeString(cmd); + if (user_exists == "true") then + row['user_exists'] = "true"; + else + row['user_exists'] = "false"; + end + end + end else --set the values external = "true";