diff --git a/resources/install/scripts/app/voicemail/index.lua b/resources/install/scripts/app/voicemail/index.lua index 93f111a308..83c6437df5 100644 --- a/resources/install/scripts/app/voicemail/index.lua +++ b/resources/install/scripts/app/voicemail/index.lua @@ -122,6 +122,28 @@ domain_uuid = string.lower(domain_uuid); end + --settings + dofile(scripts_dir.."/resources/functions/settings.lua"); + settings = settings(domain_uuid); + storage_type = ""; + if (settings['voicemail']['storage_type'] ~= nil) then + if (settings['voicemail']['storage_type']['text'] ~= nil) then + storage_type = settings['voicemail']['storage_type']['text']; + end + end + storage_path = ""; + if (settings['voicemail']['storage_path'] ~= nil) then + if (settings['voicemail']['storage_path']['text'] ~= nil) then + storage_path = settings['voicemail']['storage_path']['text']; + end + end + temp_dir = ""; + if (settings['server']['temp'] ~= nil) then + if (settings['server']['temp']['dir'] ~= nil) then + temp_dir = settings['server']['temp']['dir']; + end + end + --if voicemail_id is non numeric then get the number-alias if (voicemail_id ~= nil) then if tonumber(voicemail_id) == nil then @@ -322,11 +344,13 @@ dofile(scripts_dir.."/resources/functions/base64.lua"); --base64 encode the file - local f = io.open(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext, "rb"); - local file_content = f:read("*all"); - f:close(); - message_base64 = base64.encode(file_content); - --freeswitch.consoleLog("notice", "[voicemail] ".. message_base64 .. "\n"); + if (file_exists(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext)) then + local f = io.open(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext, "rb"); + local file_content = f:read("*all"); + f:close(); + message_base64 = base64.encode(file_content); + --freeswitch.consoleLog("notice", "[voicemail] ".. message_base64 .. "\n"); + end end --get the voicemail destinations diff --git a/resources/install/scripts/app/voicemail/resources/functions/listen_to_recording.lua b/resources/install/scripts/app/voicemail/resources/functions/listen_to_recording.lua index ccd4375dd3..05a9fdf184 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/listen_to_recording.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/listen_to_recording.lua @@ -59,28 +59,26 @@ --get the recordings from the database if (storage_type == "base64") then - if (string.len(ivr_menu_greet_long) > 1) then - sql = [[SELECT * FROM v_voicemail_messages - WHERE domain_uuid = ']] .. domain_uuid ..[[' - AND voicemail_message_uuid = ']].. uuid.. [[' ]]; - --if (debug["sql"]) then - freeswitch.consoleLog("notice", "[ivr_menu] SQL: " .. sql .. "\n"); - --end - status = dbh:query(sql, function(row) - --add functions - dofile(scripts_dir.."/resources/functions/base64.lua"); - - --set the voicemail message path - message_location = voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext; - - --save the recording to the file system - if (string.len(row["message_base64"]) > 32) then - local file = io.open(message_location, "w"); - file:write(base64.decode(row["message_base64"])); - file:close(); - end - end); + sql = [[SELECT * FROM v_voicemail_messages + WHERE domain_uuid = ']] .. domain_uuid ..[[' + AND voicemail_message_uuid = ']].. uuid.. [[' ]]; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[ivr_menu] SQL: " .. sql .. "\n"); end + status = dbh:query(sql, function(row) + --add functions + dofile(scripts_dir.."/resources/functions/base64.lua"); + + --set the voicemail message path + message_location = voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext; + + --save the recording to the file system + if (string.len(row["message_base64"]) > 32) then + local file = io.open(message_location, "w"); + file:write(base64.decode(row["message_base64"])); + file:close(); + end + end); elseif (storage_type == "http_cache") then message_location = storage_path.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext; end