From 15323f8f51e84ea769fe3952d1ff56240ebd2b21 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Fri, 22 Feb 2013 20:50:44 +0000 Subject: [PATCH] Fixed the following bug. When dialing *99 it produces this error. 2013-02-21 18:39:28.016638 [ERR] mod_lua.cpp:198 ...app/voicemail/resources/functions/record_message.lua:39: bad argument #1 to 'len' (string expected, got nil) --- .../resources/functions/record_message.lua | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/includes/install/scripts/app/voicemail/resources/functions/record_message.lua b/includes/install/scripts/app/voicemail/resources/functions/record_message.lua index 7ce1f702df..dacd1d6a40 100644 --- a/includes/install/scripts/app/voicemail/resources/functions/record_message.lua +++ b/includes/install/scripts/app/voicemail/resources/functions/record_message.lua @@ -36,27 +36,29 @@ end --direct dial - if (string.len(dtmf_digits) > 0) then - if (session:ready()) then - if (direct_dial["enabled"] == "true") then - if (string.len(dtmf_digits) < max_digits) then - dtmf_digits = dtmf_digits .. session:getDigits(direct_dial["max_digits"], "#", 5000); + if (dtmf_digits ~= nil) then + if (string.len(dtmf_digits) > 0) then + if (session:ready()) then + if (direct_dial["enabled"] == "true") then + if (string.len(dtmf_digits) < max_digits) then + dtmf_digits = dtmf_digits .. session:getDigits(direct_dial["max_digits"], "#", 5000); + end end end - end - if (session:ready()) then - freeswitch.consoleLog("notice", "[voicemail] dtmf_digits: " .. string.sub(dtmf_digits, 0, 1) .. "\n"); - if (dtmf_digits == "*") then - --check the voicemail password - check_password(voicemail_id, password_tries); - --send to the main menu - timeouts = 0; - main_menu(); - elseif (string.sub(dtmf_digits, 0, 1) == "*") then - --do not allow dialing numbers prefixed with * - session:hangup(); - else - session:transfer(dtmf_digits, "XML", context); + if (session:ready()) then + freeswitch.consoleLog("notice", "[voicemail] dtmf_digits: " .. string.sub(dtmf_digits, 0, 1) .. "\n"); + if (dtmf_digits == "*") then + --check the voicemail password + check_password(voicemail_id, password_tries); + --send to the main menu + timeouts = 0; + main_menu(); + elseif (string.sub(dtmf_digits, 0, 1) == "*") then + --do not allow dialing numbers prefixed with * + session:hangup(); + else + session:transfer(dtmf_digits, "XML", context); + end end end end