From 7265388ca108708fb7cf03849aaa9a9d470cc8c5 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Tue, 23 Sep 2014 07:45:40 +0000 Subject: [PATCH] Fix 2 problems with call forward first fix the alias and unforward. --- resources/install/scripts/call_forward.lua | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/resources/install/scripts/call_forward.lua b/resources/install/scripts/call_forward.lua index 31aedb9b54..a93c50bf69 100644 --- a/resources/install/scripts/call_forward.lua +++ b/resources/install/scripts/call_forward.lua @@ -165,6 +165,15 @@ --set the dial string if (session:ready() and enabled == "true") then + --used for number_alias to get the correct user + sql = "select * from v_extensions "; + sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; + sql = sql .. "and number_alias = '"..forward_all_destination.."' "; + status = dbh:query(sql, function(row) + destination_user = row.extension; + end); + + --set the dial_string dial_string = "{presence_id="..forward_all_destination.."@"..domain_name; dial_string = dial_string .. ",instant_ringback=true"; dial_string = dial_string .. ",domain_uuid="..domain_uuid; @@ -176,10 +185,18 @@ end dial_string = dial_string .. "}"; - cmd = "user_exists id ".. forward_all_destination .." "..domain_name; + if (destination_user ~= nil) then + cmd = "user_exists id ".. destination_user .." "..domain_name; + else + cmd = "user_exists id ".. forward_all_destination .." "..domain_name; + end user_exists = trim(api:executeString(cmd)); if (user_exists) then - dial_string = dial_string .. "user/"..forward_all_destination.."@"..domain_name; + if (destination_user ~= nil) then + dial_string = dial_string .. "user/"..destination_user.."@"..domain_name; + else + dial_string = dial_string .. "user/"..forward_all_destination.."@"..domain_name; + end else dial_string = dial_string .. "loopback/"..forward_all_destination; end @@ -214,7 +231,7 @@ end --check the destination - if (forward_all_destination == "nil") then + if (forward_all_destination == nil) then enabled = false; forward_all_enabled = "false"; else