From be0ffa16e54a29f596abc83a3f9f0f567906e184 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Fri, 27 Jan 2017 12:18:01 -0700 Subject: [PATCH] Update index.lua Prevent an error by moving the voicemail quota into the if statement that checks if the voicemail_uuid is not null. --- .../install/scripts/app/voicemail/index.lua | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/resources/install/scripts/app/voicemail/index.lua b/resources/install/scripts/app/voicemail/index.lua index f7b703277b..097c1cd007 100644 --- a/resources/install/scripts/app/voicemail/index.lua +++ b/resources/install/scripts/app/voicemail/index.lua @@ -37,8 +37,8 @@ direct_dial["max_digits"] = 4; --debug - debug["info"] = true; - debug["sql"] = true; + debug["info"] = false; + debug["sql"] = false; --get the argv values script_name = argv[1]; @@ -320,30 +320,30 @@ --leave a message if (voicemail_action == "save") then - --check the voicemail quota - if (vm_disk_quota) then - --get voicemail message seconds - local sql = [[SELECT coalesce(sum(message_length), 0) as message_sum FROM v_voicemail_messages - WHERE domain_uuid = :domain_uuid - AND voicemail_uuid = :voicemail_uuid]] - local params = {domain_uuid = domain_uuid, voicemail_uuid = voicemail_uuid}; - if (debug["sql"]) then - freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n"); - end - dbh:query(sql, params, function(row) - message_sum = row["message_sum"]; - end); - if (tonumber(vm_disk_quota) <= tonumber(message_sum)) then - --play message mailbox full - session:execute("playback", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/voicemail/vm-mailbox_full.wav") - --set the voicemail_uuid to nil to prevent saving the voicemail - voicemail_uuid = nil; - end - end - --valid voicemail if (voicemail_uuid ~= nil) then + --check the voicemail quota + if (vm_disk_quota) then + --get voicemail message seconds + local sql = [[SELECT coalesce(sum(message_length), 0) as message_sum FROM v_voicemail_messages + WHERE domain_uuid = :domain_uuid + AND voicemail_uuid = :voicemail_uuid]] + local params = {domain_uuid = domain_uuid, voicemail_uuid = voicemail_uuid}; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n"); + end + dbh:query(sql, params, function(row) + message_sum = row["message_sum"]; + end); + if (tonumber(vm_disk_quota) <= tonumber(message_sum)) then + --play message mailbox full + session:execute("playback", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/voicemail/vm-mailbox_full.wav") + --set the voicemail_uuid to nil to prevent saving the voicemail + voicemail_uuid = nil; + end + end + --play the greeting timeouts = 0; play_greeting();