mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Update forward_add_intro.lua
Use phrase:voicemail_forward_prepend and record the intro. Use the following naming convention for the intro_<uuid>.wav.
This commit is contained in:
@@ -26,30 +26,34 @@
|
|||||||
--define a function to forward a message to an extension
|
--define a function to forward a message to an extension
|
||||||
function forward_add_intro(voicemail_id, uuid)
|
function forward_add_intro(voicemail_id, uuid)
|
||||||
|
|
||||||
--connect to the database
|
--flush dtmf digits from the input buffer
|
||||||
local db = dbh or Database.new('system');
|
session:flushDigits();
|
||||||
|
|
||||||
--load libraries
|
|
||||||
local Database = require "resources.functions.database";
|
|
||||||
local Settings = require "resources.functions.lazy_settings";
|
|
||||||
|
|
||||||
--get the settings.
|
|
||||||
local settings = Settings.new(db, domain_name, domain_uuid)
|
|
||||||
--local max_len_seconds = settings:get('voicemail', 'forward_add_intro', 'boolean') or 300;
|
|
||||||
|
|
||||||
--request whether to add the intro
|
--request whether to add the intro
|
||||||
--To add an introduction to this message press 1
|
--To add an introduction to this message press 1
|
||||||
add_intro_id = macro(session, "forward_add_intro", 20, 5000, '');
|
add_intro_id = session:playAndGetDigits(1, 1, 3, 5000, "#*", "phrase:voicemail_forward_prepend:1:2", "phrase:invalid_entry", "\\d+");
|
||||||
|
freeswitch.consoleLog("notice", "[voicemail][forward add intro] "..add_intro_id.."\n");
|
||||||
if (add_intro_id == '1') then
|
if (add_intro_id == '1') then
|
||||||
|
|
||||||
|
--connect to the database
|
||||||
|
local db = dbh or Database.new('system');
|
||||||
|
|
||||||
|
--load libraries
|
||||||
|
local Database = require "resources.functions.database";
|
||||||
|
local Settings = require "resources.functions.lazy_settings";
|
||||||
|
|
||||||
|
--get the settings.
|
||||||
|
local settings = Settings.new(db, domain_name, domain_uuid);
|
||||||
|
local max_len_seconds = settings:get('voicemail', 'max_len_seconds', 'boolean') or 300;
|
||||||
|
|
||||||
--record your message at the tone press any key or stop talking to end the recording
|
--record your message at the tone press any key or stop talking to end the recording
|
||||||
if (session:ready()) then
|
if (session:ready()) then
|
||||||
result = macro(session, "record_message", 0, 5000, '');
|
session:sayPhrase("voicemail_record_greeting", "", "en")
|
||||||
end
|
end
|
||||||
|
|
||||||
--set the file full path
|
--set the file full path
|
||||||
message_location = voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext;
|
message_location = voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext;
|
||||||
message_intro_location = voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext;
|
message_intro_location = voicemail_dir.."/"..voicemail_id.."/intro_"..uuid.."."..vm_message_ext;
|
||||||
|
|
||||||
--record the message introduction
|
--record the message introduction
|
||||||
-- syntax is session:recordFile(file_name, max_len_secs, silence_threshold, silence_secs)
|
-- syntax is session:recordFile(file_name, max_len_secs, silence_threshold, silence_secs)
|
||||||
@@ -96,7 +100,7 @@
|
|||||||
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", "[voicemail] SQL: " .. sql .. "\n");
|
||||||
end
|
end
|
||||||
status = dbh:query(sql, function(row)
|
status = dbh:query(sql, function(row)
|
||||||
--add functions
|
--add functions
|
||||||
@@ -115,13 +119,6 @@
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--merge the intro and the voicemail recording
|
|
||||||
cmd = "sox "..message_intro_location.." "..message_location;
|
|
||||||
os.execute(cmd);
|
|
||||||
|
|
||||||
--remove the intro file after it has been merged
|
|
||||||
os.remove(message_intro_location);
|
|
||||||
|
|
||||||
--save the merged file into the database as base64
|
--save the merged file into the database as base64
|
||||||
if (storage_type == "base64") then
|
if (storage_type == "base64") then
|
||||||
--get the content of the file
|
--get the content of the file
|
||||||
|
|||||||
Reference in New Issue
Block a user