Voicemail: Integrate message forward intro playback in web interface, and prepend intro on emailed audio file.
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
--flush dtmf digits from the input buffer
|
||||
session:flushDigits();
|
||||
--delete the file
|
||||
os.remove(voicemail_dir.."/"..voicemail_id.."/intro_msg_"..uuid.."."..vm_message_ext);
|
||||
os.remove(voicemail_dir.."/"..voicemail_id.."/intro_"..uuid.."."..vm_message_ext);
|
||||
os.remove(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext);
|
||||
--delete from the database
|
||||
|
||||
+9
-7
@@ -53,8 +53,7 @@
|
||||
session:streamFile("tone_stream://L=1;%(1000, 0, 640)");
|
||||
end
|
||||
|
||||
--set the file full path
|
||||
message_location = voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext;
|
||||
--set the full message intro path
|
||||
message_intro_location = voicemail_dir.."/"..voicemail_id.."/intro_"..uuid.."."..vm_message_ext;
|
||||
|
||||
--record the message introduction
|
||||
@@ -100,13 +99,13 @@
|
||||
local file = require "resources.functions.file"
|
||||
|
||||
--get the content of the file
|
||||
local file_content = assert(file.read_base64(message_intro_location));
|
||||
file_content = assert(file.read_base64(message_intro_location));
|
||||
|
||||
--save the merged file as base64
|
||||
local sql = [[UPDATE SET v_voicemail_messages
|
||||
SET message_intro_base64 = :file_content
|
||||
WHERE domain_uuid = :domain_uuid
|
||||
AND voicemail_message_uuid = :uuid]];
|
||||
local sql = [[UPDATE v_voicemail_messages
|
||||
SET message_intro_base64 = :file_content
|
||||
WHERE domain_uuid = :domain_uuid
|
||||
AND voicemail_message_uuid = :uuid]];
|
||||
local params = {file_content = file_content, domain_uuid = domain_uuid, uuid = uuid};
|
||||
|
||||
if (debug["sql"]) then
|
||||
@@ -116,6 +115,9 @@
|
||||
local dbh = Database.new('system', 'base64')
|
||||
dbh:query(sql, params)
|
||||
dbh:release()
|
||||
|
||||
--delete intro file
|
||||
os.remove(message_intro_location);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+5
-1
@@ -65,6 +65,7 @@
|
||||
message_length = row["message_length"];
|
||||
message_status = row["message_status"];
|
||||
message_priority = row["message_priority"];
|
||||
message_intro_base64 = row["message_intro_base64"];
|
||||
message_base64 = row["message_base64"];
|
||||
end);
|
||||
end
|
||||
@@ -97,6 +98,7 @@
|
||||
table.insert(sql, "domain_uuid, ");
|
||||
table.insert(sql, "voicemail_uuid, ");
|
||||
if (storage_type == "base64") then
|
||||
table.insert(sql, "message_intro_base64, ");
|
||||
table.insert(sql, "message_base64, ");
|
||||
end
|
||||
table.insert(sql, "created_epoch, ");
|
||||
@@ -112,6 +114,7 @@
|
||||
table.insert(sql, ":domain_uuid, ");
|
||||
table.insert(sql, ":forward_voicemail_uuid, ");
|
||||
if (storage_type == "base64") then
|
||||
table.insert(sql, ":message_intro_base64, ");
|
||||
table.insert(sql, ":message_base64, ");
|
||||
end
|
||||
table.insert(sql, ":created_epoch, ");
|
||||
@@ -126,6 +129,7 @@
|
||||
voicemail_message_uuid = voicemail_message_uuid;
|
||||
domain_uuid = domain_uuid;
|
||||
forward_voicemail_uuid = forward_voicemail_uuid;
|
||||
message_intro_base64 = message_intro_base64;
|
||||
message_base64 = message_base64;
|
||||
created_epoch = created_epoch;
|
||||
caller_id_name = caller_id_name;
|
||||
@@ -157,7 +161,7 @@
|
||||
mwi_notify(forward_voicemail_id.."@"..domain_name, new_messages, saved_messages)
|
||||
blf_notify(tonumber(new_messages) > 0, "voicemail+" .. forward_voicemail_id .. "@" .. domain_name)
|
||||
|
||||
--if local after email is true then copy the recording file
|
||||
--if storage type is not base64 then copy the recording file
|
||||
if (storage_type ~= "base64") then
|
||||
mkdir(voicemail_dir.."/"..forward_voicemail_id);
|
||||
copy(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext, voicemail_dir.."/"..forward_voicemail_id.."/msg_"..voicemail_message_uuid.."."..vm_message_ext);
|
||||
|
||||
@@ -144,16 +144,22 @@
|
||||
--message_priority = row["message_priority"];
|
||||
--get the recordings from the database
|
||||
if (storage_type == "base64") then
|
||||
--set the voicemail message path
|
||||
--set the voicemail intro and message paths
|
||||
message_location = voicemail_dir.."/"..id.."/msg_"..uuid.."."..vm_message_ext;
|
||||
intro_location = voicemail_dir.."/"..id.."/intro_"..uuid.."."..vm_message_ext;
|
||||
|
||||
--save the recording to the file system
|
||||
--save the recordings to the file system
|
||||
if (string.len(row["message_base64"]) > 32) then
|
||||
--include the file io
|
||||
local file = require "resources.functions.file"
|
||||
|
||||
--write decoded string to file
|
||||
--write decoded message string to file
|
||||
file.write_base64(message_location, row["message_base64"]);
|
||||
|
||||
--write decoded intro string to file, if any
|
||||
if (string.len(row["message_intro_base64"]) > 32) then
|
||||
file.write_base64(intro_location, row["message_intro_base64"]);
|
||||
end
|
||||
end
|
||||
end
|
||||
end);
|
||||
@@ -229,6 +235,16 @@
|
||||
--prepare file
|
||||
file = voicemail_dir.."/"..id.."/msg_"..uuid.."."..vm_message_ext;
|
||||
|
||||
--find the location of sox, if installed
|
||||
sox = os.execute('which sox');
|
||||
|
||||
--combine intro, if exists, with message for emailing (only)
|
||||
intro = voicemail_dir.."/"..id.."/intro_"..uuid.."."..vm_message_ext;
|
||||
combined = voicemail_dir.."/"..id.."/intro_msg_"..uuid.."."..vm_message_ext;
|
||||
if (file_exists(intro) and sox ~= nil and sox ~= '') then
|
||||
os.execute(sox.." "..intro.." "..file.." "..combined);
|
||||
end
|
||||
|
||||
--prepare the subject
|
||||
if (subject ~= nil) then
|
||||
subject = subject:gsub("${caller_id_name}", caller_id_name);
|
||||
@@ -308,13 +324,22 @@
|
||||
smtp_from = smtp_from_name.."<"..smtp_from..">";
|
||||
end
|
||||
|
||||
--send the email
|
||||
send_mail(headers,
|
||||
smtp_from,
|
||||
voicemail_mail_to,
|
||||
{subject, body},
|
||||
(voicemail_file == "attach") and file
|
||||
);
|
||||
--send the email with, or without, including the intro
|
||||
if (file_exists(combined)) then
|
||||
send_mail(headers,
|
||||
smtp_from,
|
||||
voicemail_mail_to,
|
||||
{subject, body},
|
||||
(voicemail_file == "attach") and combined
|
||||
);
|
||||
else
|
||||
send_mail(headers,
|
||||
smtp_from,
|
||||
voicemail_mail_to,
|
||||
{subject, body},
|
||||
(voicemail_file == "attach") and file
|
||||
);
|
||||
end
|
||||
end
|
||||
|
||||
--whether to keep the voicemail message and details local after email
|
||||
@@ -331,19 +356,31 @@
|
||||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||
end
|
||||
dbh:query(sql, params);
|
||||
--delete voicemail recording file
|
||||
--delete voicemail recording files
|
||||
if (file_exists(file)) then
|
||||
os.remove(file);
|
||||
end
|
||||
if (file_exists(intro)) then
|
||||
os.remove(intro);
|
||||
end
|
||||
if (file_exists(combined)) then
|
||||
os.remove(combined);
|
||||
end
|
||||
--set message waiting indicator
|
||||
message_waiting(id, domain_uuid);
|
||||
--clear the variable
|
||||
db_voicemail_uuid = '';
|
||||
elseif (storage_type == "base64") then
|
||||
--delete voicemail recording file
|
||||
--delete voicemail recording files
|
||||
if (file_exists(file)) then
|
||||
os.remove(file);
|
||||
end
|
||||
if (file_exists(intro)) then
|
||||
os.remove(intro);
|
||||
end
|
||||
if (file_exists(combined)) then
|
||||
os.remove(combined);
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user