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.

This commit is contained in:
Mark Crane
2015-04-18 18:19:22 +00:00
parent 48f7524e35
commit 8231e6bfde
2 changed files with 27 additions and 4 deletions
@@ -66,6 +66,9 @@
--play the greeting --play the greeting
session:streamFile(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav"); session:streamFile(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav");
--delete the greeting
os.remove(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav");
end); end);
elseif (storage_type == "http_cache") then elseif (storage_type == "http_cache") then
session:streamFile(storage_path.."/"..voicemail_id.."/greeting_"..greeting_id..".wav"); session:streamFile(storage_path.."/"..voicemail_id.."/greeting_"..greeting_id..".wav");
@@ -70,6 +70,21 @@
message_length = row["message_length"]; message_length = row["message_length"];
--message_status = row["message_status"]; --message_status = row["message_status"];
--message_priority = row["message_priority"]; --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); end);
--format the message length and date --format the message length and date
@@ -148,7 +163,6 @@
freeswitch.consoleLog("notice", "[voicemail] cmd: " .. cmd .. "\n"); freeswitch.consoleLog("notice", "[voicemail] cmd: " .. cmd .. "\n");
end end
result = api:executeString(cmd); result = api:executeString(cmd);
end end
--whether to keep the voicemail message and details local after email --whether to keep the voicemail message and details local after email
@@ -173,4 +187,10 @@
db_voicemail_uuid = ''; db_voicemail_uuid = '';
end end
end end
if (storage_type == "base64") then
--delete voicemail recording file
if (file_exists(file)) then
os.remove(file);
end
end
end end