Prevent errors in the dial string lua script

This commit is contained in:
Mark Crane 2014-04-15 18:54:03 +00:00
parent 7f8289737a
commit a721ca6758
1 changed files with 41 additions and 35 deletions

View File

@ -16,7 +16,7 @@
--
-- The Initial Developer of the Original Code is
-- Mark J Crane <markjcrane@fusionpbx.com>
-- Copyright (C) 2010
-- Copyright (C) 2010 - 2014
-- the Initial Developer. All Rights Reserved.
--
-- Contributor(s):
@ -84,6 +84,7 @@ if ( session:ready() ) then
caller_pin_number = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_pass:#", "", "\\d+");
--get the dial_string, and extension_uuid
if (string.len(unique_id) > 0) then
sql = "SELECT * FROM v_extensions as e, v_domains as d ";
sql = sql .. "WHERE e.domain_uuid = d.domain_uuid ";
if (extension == "true") then
@ -104,6 +105,7 @@ if ( session:ready() ) then
db_dial_user = row.dial_user;
db_dial_domain = row.dial_domain;
end);
end
--check to see if the pin number is correct
if (pin_number) then
@ -112,6 +114,7 @@ if ( session:ready() ) then
db_extension_uuid = "";
end
else
if (db_domain_uuid ~= nil) then
sql = "SELECT * FROM v_voicemails ";
sql = sql .. "WHERE domain_uuid = '" .. db_domain_uuid .."' ";
if (tonumber(db_extension) == nil) then
@ -127,6 +130,7 @@ if ( session:ready() ) then
db_extension_uuid = "";
end
end
end
--process the request
if (string.len(db_extension_uuid) > 0) then
@ -192,7 +196,9 @@ if ( session:ready() ) then
end
end
--clear the cache
if (db_extension ~= nil) then
api:execute("memcache", "delete directory:"..db_extension.."@"..context);
end
else
session:streamFile("phrase:voicemail_fail_auth:#");
session:hangup("NORMAL_CLEARING");