Additional work on voicemail with base64.
This commit is contained in:
@@ -122,6 +122,28 @@
|
|||||||
domain_uuid = string.lower(domain_uuid);
|
domain_uuid = string.lower(domain_uuid);
|
||||||
end
|
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 is non numeric then get the number-alias
|
||||||
if (voicemail_id ~= nil) then
|
if (voicemail_id ~= nil) then
|
||||||
if tonumber(voicemail_id) == nil then
|
if tonumber(voicemail_id) == nil then
|
||||||
@@ -322,11 +344,13 @@
|
|||||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||||
|
|
||||||
--base64 encode the file
|
--base64 encode the file
|
||||||
local f = io.open(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext, "rb");
|
if (file_exists(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext)) then
|
||||||
local file_content = f:read("*all");
|
local f = io.open(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext, "rb");
|
||||||
f:close();
|
local file_content = f:read("*all");
|
||||||
message_base64 = base64.encode(file_content);
|
f:close();
|
||||||
--freeswitch.consoleLog("notice", "[voicemail] ".. message_base64 .. "\n");
|
message_base64 = base64.encode(file_content);
|
||||||
|
--freeswitch.consoleLog("notice", "[voicemail] ".. message_base64 .. "\n");
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--get the voicemail destinations
|
--get the voicemail destinations
|
||||||
|
|||||||
+19
-21
@@ -59,28 +59,26 @@
|
|||||||
|
|
||||||
--get the recordings from the database
|
--get the recordings from the database
|
||||||
if (storage_type == "base64") then
|
if (storage_type == "base64") then
|
||||||
if (string.len(ivr_menu_greet_long) > 1) then
|
sql = [[SELECT * FROM v_voicemail_messages
|
||||||
sql = [[SELECT * FROM v_voicemail_messages
|
WHERE domain_uuid = ']] .. domain_uuid ..[['
|
||||||
WHERE domain_uuid = ']] .. domain_uuid ..[['
|
AND voicemail_message_uuid = ']].. uuid.. [[' ]];
|
||||||
AND voicemail_message_uuid = ']].. uuid.. [[' ]];
|
if (debug["sql"]) then
|
||||||
--if (debug["sql"]) then
|
freeswitch.consoleLog("notice", "[ivr_menu] SQL: " .. sql .. "\n");
|
||||||
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);
|
|
||||||
end
|
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
|
elseif (storage_type == "http_cache") then
|
||||||
message_location = storage_path.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext;
|
message_location = storage_path.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext;
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user