mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-02 02:03:48 +00:00
Additional work on option to save files in base64 for voicemail and ivr menu.
This commit is contained in:
@@ -304,10 +304,10 @@
|
||||
if (storage_type == "base64") then
|
||||
--show the storage type
|
||||
freeswitch.consoleLog("notice", "[voicemail] ".. storage_type .. "\n");
|
||||
|
||||
|
||||
--include the base64 function
|
||||
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");
|
||||
@@ -441,7 +441,7 @@
|
||||
send_email(voicemail_id_copy, voicemail_message_uuid);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--remove initial recording file
|
||||
if (file_exists(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext)) then
|
||||
os.remove(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext);
|
||||
|
||||
@@ -70,6 +70,35 @@
|
||||
dbh:query(sql);
|
||||
end
|
||||
|
||||
--get the greeting from the database
|
||||
if (storage_type == "base64") then
|
||||
if (string.len(ivr_menu_greet_long) > 1) then
|
||||
sql = [[SELECT * FROM v_voicemail_greetings
|
||||
WHERE domain_uuid = ']] .. domain_uuid ..[['
|
||||
AND voicemail_id = ']].. voicemail_id.. [['
|
||||
AND greeting_id = ']].. greeting_id.. [[' ]];
|
||||
--if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n");
|
||||
--end
|
||||
status = dbh:query(sql, function(row)
|
||||
--add functions
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
|
||||
--set the voicemail message path
|
||||
greeting_location = voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav"; --vm_message_ext;
|
||||
|
||||
--save the greeting to the file system
|
||||
if (string.len(row["greeting_base64"]) > 32) then
|
||||
local file = io.open(greeting_location, "w");
|
||||
file:write(base64.decode(row["greeting_base64"]));
|
||||
file:close();
|
||||
end
|
||||
end);
|
||||
end
|
||||
elseif (storage_type == "http_cache") then
|
||||
--need additional work
|
||||
end
|
||||
|
||||
--play the greeting
|
||||
if (session:ready()) then
|
||||
if (file_exists(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav")) then
|
||||
|
||||
@@ -47,16 +47,44 @@
|
||||
session:say(message_number, default_language, "NUMBER", "pronounced");
|
||||
end
|
||||
end
|
||||
|
||||
--say the message date
|
||||
if (session:ready()) then
|
||||
if (string.len(dtmf_digits) == 0) then
|
||||
if (current_time_zone ~= nil) then
|
||||
session:execute("set", "timezone="..current_time_zone.."");
|
||||
end
|
||||
--say the message date
|
||||
if (session:ready()) then
|
||||
if (string.len(dtmf_digits) == 0) then
|
||||
if (current_time_zone ~= nil) then
|
||||
session:execute("set", "timezone="..current_time_zone.."");
|
||||
end
|
||||
session:say(created_epoch, default_language, "CURRENT_DATE_TIME", "pronounced");
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--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);
|
||||
end
|
||||
elseif (storage_type == "http_cache") then
|
||||
--need additional work
|
||||
end
|
||||
|
||||
--play the message
|
||||
if (session:ready()) then
|
||||
if (string.len(dtmf_digits) == 0) then
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
--message_status new,saved
|
||||
if (session:ready()) then
|
||||
if (voicemail_id ~= nil) then
|
||||
sql = [[SELECT * FROM v_voicemail_messages
|
||||
sql = [[SELECT voicemail_message_uuid, created_epoch, caller_id_name, caller_id_number FROM v_voicemail_messages
|
||||
WHERE domain_uuid = ']] .. domain_uuid ..[['
|
||||
AND voicemail_uuid = ']] .. voicemail_uuid ..[[']]
|
||||
if (message_status == "new") then
|
||||
|
||||
@@ -40,9 +40,39 @@
|
||||
--play the greeting
|
||||
dtmf_digits = '';
|
||||
if (string.len(greeting_id) > 0) then
|
||||
|
||||
--get the greeting from the database
|
||||
if (storage_type == "base64") then
|
||||
if (string.len(ivr_menu_greet_long) > 1) then
|
||||
sql = [[SELECT * FROM v_voicemail_greetings
|
||||
WHERE domain_uuid = ']] .. domain_uuid ..[['
|
||||
AND voicemail_id = ']].. voicemail_id.. [['
|
||||
AND greeting_id = ']].. greeting_id.. [[' ]];
|
||||
--if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n");
|
||||
--end
|
||||
status = dbh:query(sql, function(row)
|
||||
--add functions
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
|
||||
--set the voicemail message path
|
||||
greeting_location = voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav"; --vm_message_ext;
|
||||
|
||||
--save the greeting to the file system
|
||||
if (string.len(row["greeting_base64"]) > 32) then
|
||||
local file = io.open(greeting_location, "w");
|
||||
file:write(base64.decode(row["greeting_base64"]));
|
||||
file:close();
|
||||
end
|
||||
end);
|
||||
end
|
||||
elseif (storage_type == "http_cache") then
|
||||
--need additional work
|
||||
end
|
||||
|
||||
--custom greeting
|
||||
session:streamFile(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav");
|
||||
session:streamFile("silence_stream://200");
|
||||
session:streamFile(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav");
|
||||
session:streamFile("silence_stream://200");
|
||||
else
|
||||
--default greeting
|
||||
dtmf_digits = macro(session, "person_not_available_record_message", 1, 200);
|
||||
|
||||
@@ -34,14 +34,61 @@
|
||||
dtmf_digits = '';
|
||||
macro(session, "record_name", 1, 100, '');
|
||||
|
||||
--save the recording
|
||||
--prepate to record
|
||||
-- syntax is session:recordFile(file_name, max_len_secs, silence_threshold, silence_secs)
|
||||
max_len_seconds = 30;
|
||||
silence_threshold = 30;
|
||||
silence_seconds = 5;
|
||||
mkdir(voicemail_dir.."/"..voicemail_id);
|
||||
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/recorded_name.wav", max_len_seconds, silence_threshold, silence_seconds);
|
||||
--session:execute("record", voicemail_dir.."/"..uuid.." 180 200");
|
||||
|
||||
--record and save the file
|
||||
if (storage_type == "base64") then
|
||||
--include the base64 function
|
||||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
|
||||
--set the location
|
||||
voicemail_name_location = voicemail_dir.."/"..voicemail_id.."/recorded_name.wav";
|
||||
|
||||
--record the file to the file system
|
||||
-- syntax is session:recordFile(file_name, max_len_secs, silence_threshold, silence_secs);
|
||||
result = session:recordFile(voicemail_name_location, max_len_seconds, silence_threshold, silence_seconds);
|
||||
--session:execute("record", voicemail_dir.."/"..uuid.." 180 200");
|
||||
|
||||
--show the storage type
|
||||
freeswitch.consoleLog("notice", "[recordings] ".. storage_type .. "\n");
|
||||
|
||||
--base64 encode the file
|
||||
local f = io.open(voicemail_name_location, "rb");
|
||||
local file_content = f:read("*all");
|
||||
f:close();
|
||||
voicemail_name_base64 = base64.encode(file_content);
|
||||
|
||||
--update the voicemail name
|
||||
sql = "UPDATE v_voicemails ";
|
||||
sql = sql .. "set voicemail_name_base64 = '".. voicemail_name_base64 .. "' ";
|
||||
sql = sql .. "where domain_uuid = '".. domain_uuid .. "' ";
|
||||
sql = sql .. "and voicemail_id = '".. voicemail_id .."'";
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[recording] SQL: " .. sql .. "\n");
|
||||
end
|
||||
if (storage_type == "base64") then
|
||||
array = explode("://", database["system"]);
|
||||
local luasql = require "luasql.postgres";
|
||||
local env = assert (luasql.postgres());
|
||||
local dbh = env:connect(array[2]);
|
||||
res, serr = dbh:execute(sql);
|
||||
dbh:close();
|
||||
env:close();
|
||||
else
|
||||
dbh:query(sql);
|
||||
end
|
||||
elseif (storage_type == "http_cache") then
|
||||
freeswitch.consoleLog("notice", "[voicemail] ".. storage_type .. " ".. storage_path .."\n");
|
||||
session:execute("record", storage_path .."/"..recording_name);
|
||||
else
|
||||
-- syntax is session:recordFile(file_name, max_len_secs, silence_threshold, silence_secs);
|
||||
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/recorded_name.wav", max_len_seconds, silence_threshold, silence_seconds);
|
||||
end
|
||||
|
||||
--play the name
|
||||
--session:streamFile(voicemail_dir.."/"..voicemail_id.."/recorded_name.wav");
|
||||
|
||||
Reference in New Issue
Block a user