Voicemail - Edit: Add option to Keep Local After Forward (or not).

This commit is contained in:
fusionate
2024-06-21 17:24:06 -06:00
parent 1ef5f1dab0
commit 81af0fefd1
5 changed files with 171 additions and 16 deletions

View File

@@ -288,16 +288,20 @@
voicemail_mail_to = row["voicemail_mail_to"];
voicemail_attach_file = row["voicemail_attach_file"];
voicemail_local_after_email = row["voicemail_local_after_email"];
voicemail_local_after_forward = row["voicemail_local_after_forward"];
voicemail_transcription_enabled = row["voicemail_transcription_enabled"];
voicemail_tutorial = row["voicemail_tutorial"];
end);
--set default values
if (voicemail_attach_file == nil) then
voicemail_attach_file = "true";
end
if (voicemail_local_after_email == nil) then
voicemail_local_after_email = "true";
end
if (voicemail_attach_file == nil) then
voicemail_attach_file = "true";
if (voicemail_local_after_forward == nil) then
voicemail_local_after_forward = "true";
end
--valid voicemail
@@ -392,15 +396,19 @@
end
dbh:query(sql, params, function(row)
voicemail_local_after_email = row["voicemail_local_after_email"];
voicemail_local_after_forward = row["voicemail_local_after_forward"];
end);
--set default values
if (voicemail_local_after_email == nil) then
voicemail_local_after_email = "true";
end
if (voicemail_local_after_forward == nil) then
voicemail_local_after_forward = "true";
end
--get the message count and send the mwi event
if (voicemail_local_after_email == 'true') then
if (voicemail_local_after_email == 'true' or voicemail_local_after_forward == 'true') then
message_waiting(voicemail_id, domain_uuid);
end
end
@@ -672,6 +680,37 @@
end
end --for
--whether to keep the voicemail message and details local after forward
if (voicemail_local_after_email == "false" and voicemail_local_after_forward == "false") then
--delete the voicemail message details
local sql = [[DELETE FROM v_voicemail_messages
WHERE domain_uuid = :domain_uuid
AND voicemail_uuid = :voicemail_uuid
AND voicemail_message_uuid = :uuid]]
local params = {
domain_uuid = domain_uuid,
voicemail_uuid = voicemail_uuid,
uuid = uuid
};
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
end
dbh:query(sql, params);
--delete voicemail recording file
if (file_exists(full_path)) then
os.remove(full_path);
end
--set message waiting indicator
message_waiting(voicemail_id, domain_uuid);
--clear the variable
db_voicemail_uuid = '';
elseif (storage_type == "base64") then
--delete voicemail recording file
if (file_exists(full_path)) then
os.remove(full_path);
end
end
else
--voicemail not enabled or does not exist
if (session ~= nil and session:ready()) then

View File

@@ -52,15 +52,19 @@
voicemail_transcription_enabled = row["voicemail_transcription_enabled"];
voicemail_file = row["voicemail_file"];
voicemail_local_after_email = row["voicemail_local_after_email"];
voicemail_local_after_forward = row["voicemail_local_after_forward"];
voicemail_description = row["voicemail_description"];
end);
--set default values
if (voicemail_file == nil) then
voicemail_file = "listen";
end
if (voicemail_local_after_email == nil) then
voicemail_local_after_email = "true";
end
if (voicemail_file == nil) then
voicemail_file = "listen";
if (voicemail_local_after_forward == nil) then
voicemail_local_after_forward = "true";
end
--require the email address to send the email
@@ -194,13 +198,20 @@
--get the link_address
link_address = http_protocol.."://"..domain_name..project_path;
--set proper delete status
if (voicemail_local_after_email == "false" and voicemail_local_after_forward == "false") then
local local_after_email = "false";
else
local local_after_email = "true";
end
--prepare the headers
local headers = {
["X-FusionPBX-Domain-UUID"] = domain_uuid;
["X-FusionPBX-Domain-Name"] = domain_name;
["X-FusionPBX-Call-UUID"] = uuid;
["X-FusionPBX-Email-Type"] = 'voicemail';
["X-FusionPBX-local_after_email"] = voicemail_local_after_email;
["X-FusionPBX-Call-UUID"] = uuid;
["X-FusionPBX-Email-Type"] = 'voicemail';
["X-FusionPBX-local_after_email"] = local_after_email;
}
--prepare the voicemail_name_formatted
@@ -307,7 +318,7 @@
--whether to keep the voicemail message and details local after email
if (string.len(voicemail_mail_to) > 2 and email_queue_enabled == 'false') then
if (voicemail_local_after_email == "false") then
if (voicemail_local_after_email == "false" and voicemail_local_after_forward == "false") then
--delete the voicemail message details
local sql = [[DELETE FROM v_voicemail_messages
WHERE domain_uuid = :domain_uuid