Require the message to be 3 seconds or longer to save the recording. Remove a session:ready from the send_email function to fix voicemail to email.
This commit is contained in:
parent
00e0f9c5b8
commit
675cfb385c
|
|
@ -89,7 +89,9 @@
|
|||
|
||||
--set the voicemail_dir
|
||||
voicemail_dir = base_dir.."/storage/voicemail/default/"..domain_name;
|
||||
--freeswitch.consoleLog("notice", "[voicemail] voicemail_dir: " .. voicemail_dir .. "\n");
|
||||
if (debug["info"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] voicemail_dir: " .. voicemail_dir .. "\n");
|
||||
end
|
||||
|
||||
--check if a file exists
|
||||
function file_exists(name)
|
||||
|
|
@ -129,7 +131,9 @@
|
|||
--do nothing
|
||||
else
|
||||
voicemail_id = get_voicemail_id();
|
||||
--freeswitch.consoleLog("notice", "[voicemail] voicemail id: " .. voicemail_id .. "\n");
|
||||
if (debug["info"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] voicemail id: " .. voicemail_id .. "\n");
|
||||
end
|
||||
end
|
||||
|
||||
--get the voicemail settings from the database
|
||||
|
|
@ -578,7 +582,9 @@
|
|||
|
||||
--start epoch
|
||||
start_epoch = os.time();
|
||||
if (debug["info"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] start epoch: " .. start_epoch .. "\n");
|
||||
end
|
||||
|
||||
--save the recording
|
||||
-- syntax is session:recordFile(file_name, max_len_secs, silence_threshold, silence_secs)
|
||||
|
|
@ -591,15 +597,21 @@
|
|||
|
||||
--stop epoch
|
||||
stop_epoch = os.time();
|
||||
if (debug["info"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] start epoch: " .. stop_epoch .. "\n");
|
||||
end
|
||||
|
||||
--calculate the message length
|
||||
message_length = stop_epoch - start_epoch;
|
||||
message_length_formatted = format_seconds(message_length);
|
||||
if (debug["info"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] message length: " .. message_length .. "\n");
|
||||
end
|
||||
|
||||
--if the recording is below the minmal length then re-record the message
|
||||
if (message_length < 4) then
|
||||
if (message_length > 2) then
|
||||
--continue
|
||||
else
|
||||
if (session:ready()) then
|
||||
--your recording is below the minimal acceptable length, please try again
|
||||
macro(session, "too_small", 100);
|
||||
|
|
@ -659,7 +671,6 @@
|
|||
|
||||
--define a function to send email
|
||||
function send_email(uuid)
|
||||
if (session:ready()) then
|
||||
--get voicemail message details
|
||||
sql = [[SELECT * FROM v_voicemail_messages
|
||||
WHERE domain_uuid = ']] .. domain_uuid ..[['
|
||||
|
|
@ -680,7 +691,9 @@
|
|||
|
||||
--calculate the message length
|
||||
message_length_formatted = format_seconds(message_length);
|
||||
if (debug["info"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] message length: " .. message_length .. "\n");
|
||||
end
|
||||
|
||||
--send the email
|
||||
message = [[<font face=arial>
|
||||
|
|
@ -705,7 +718,6 @@
|
|||
);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--define a function to forward a message to an extension
|
||||
function forward_to_extension(uuid)
|
||||
|
|
@ -806,7 +818,7 @@
|
|||
end
|
||||
|
||||
--send the email with the voicemail recording attached
|
||||
if (string.len(forward_voicemail_mail_to) > 3) then
|
||||
if (string.len(forward_voicemail_mail_to) > 2) then
|
||||
send_email(uuid);
|
||||
end
|
||||
end
|
||||
|
|
@ -828,6 +840,7 @@
|
|||
record_message();
|
||||
|
||||
--save the message to the voicemail messages
|
||||
if (message_length > 2) then
|
||||
local sql = {}
|
||||
table.insert(sql, "INSERT INTO v_voicemail_messages ");
|
||||
table.insert(sql, "(");
|
||||
|
|
@ -860,17 +873,22 @@
|
|||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n");
|
||||
end
|
||||
dbh:query(sql);
|
||||
end
|
||||
|
||||
--set the message waiting event
|
||||
if (message_length > 2) then
|
||||
local event = freeswitch.Event("message_waiting");
|
||||
event:addHeader("MWI-Messages-Waiting", "yes");
|
||||
event:addHeader("MWI-Message-Account", "sip:"..voicemail_id.."@"..domain_name);
|
||||
event:fire();
|
||||
end
|
||||
|
||||
--send the email with the voicemail recording attached
|
||||
if (message_length > 2) then
|
||||
if (string.len(voicemail_mail_to) > 3) then
|
||||
send_email(uuid);
|
||||
end
|
||||
end
|
||||
|
||||
--local after email is false so delete the recording file
|
||||
if (voicemail_local_after_email == "false") then
|
||||
|
|
@ -1129,7 +1147,9 @@ function menu_messages (message_status)
|
|||
message_number = message_number + 1;
|
||||
--listen to the message
|
||||
if (session:ready()) then
|
||||
if (debug["info"]) then
|
||||
freeswitch.consoleLog("notice", message_number.." "..string.lower(row["voicemail_message_uuid"]).." "..row["created_epoch"]);
|
||||
end
|
||||
listen_to_recording(message_number, string.lower(row["voicemail_message_uuid"]), row["created_epoch"], row["caller_id_name"], row["caller_id_number"]);
|
||||
end
|
||||
end);
|
||||
|
|
|
|||
Loading…
Reference in New Issue