From 150093780867430f6ae6584b9450cd1b0533e2ce Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Sat, 18 Apr 2015 18:19:22 +0000 Subject: [PATCH] When using base64 after playing the greeting remove the file from the file system. When sending the email get it from the database save it to the file system. Then send the email and afterwards remove it. --- .../resources/functions/play_greeting.lua | 3 ++ .../resources/functions/send_email.lua | 28 ++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/resources/install/scripts/app/voicemail/resources/functions/play_greeting.lua b/resources/install/scripts/app/voicemail/resources/functions/play_greeting.lua index dca3124adc..a934a80c5c 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/play_greeting.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/play_greeting.lua @@ -66,6 +66,9 @@ --play the greeting session:streamFile(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav"); + + --delete the greeting + os.remove(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav"); end); elseif (storage_type == "http_cache") then session:streamFile(storage_path.."/"..voicemail_id.."/greeting_"..greeting_id..".wav"); diff --git a/resources/install/scripts/app/voicemail/resources/functions/send_email.lua b/resources/install/scripts/app/voicemail/resources/functions/send_email.lua index 7409d1040a..9de054e5cc 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/send_email.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/send_email.lua @@ -53,7 +53,7 @@ if (string.len(voicemail_mail_to) > 2) then --include languages file dofile(scripts_dir.."/app/voicemail/app_languages.lua"); - + --get voicemail message details sql = [[SELECT * FROM v_voicemail_messages WHERE domain_uuid = ']] .. domain_uuid ..[[' @@ -70,6 +70,21 @@ message_length = row["message_length"]; --message_status = row["message_status"]; --message_priority = row["message_priority"]; + --get the recordings from the database + if (storage_type == "base64") then + --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 f = io.open(message_location, "w"); + f:write(base64.decode(row["message_base64"])); + f:close(); + end + end end); --format the message length and date @@ -148,7 +163,6 @@ freeswitch.consoleLog("notice", "[voicemail] cmd: " .. cmd .. "\n"); end result = api:executeString(cmd); - end --whether to keep the voicemail message and details local after email @@ -166,11 +180,17 @@ --delete voicemail recording file if (file_exists(file)) then os.remove(file); - end + end --set message waiting indicator message_waiting(id, domain_uuid); --clear the variable db_voicemail_uuid = ''; end end - end + if (storage_type == "base64") then + --delete voicemail recording file + if (file_exists(file)) then + os.remove(file); + end + end + end \ No newline at end of file