Update index.lua

Prevent an error when the voicemail_uuid is empty when the voicemail box is disabled.
This commit is contained in:
FusionPBX
2017-01-27 12:22:12 -07:00
committed by GitHub
parent ba64113e51
commit 641e026474

View File

@@ -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();