Retain recording display name and reset digit timeout (#6163)

This commit fixes 2 issues:
1. The recording name was not preserved upon
rerecording

2. When selecting rerecord, the digit timeout would retain
the value of 100, preventing the user from selecting the recording
id
This commit is contained in:
yois615 2022-08-22 13:15:23 -04:00 committed by GitHub
parent fa270a4ee8
commit 6e2e54922f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 18 deletions

View File

@ -109,18 +109,18 @@
if (not silence_thresh) then silence_thresh = '200'; end
if (not silence_hits) then silence_hits = '10'; end
--select the recording number and set the recording name
--select the recording number and set the recording filename
if (recording_id == nil) then
min_digits = 1;
max_digits = 20;
session:sleep(1000);
recording_id = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-id_number.wav", "", "\\d+");
session:setVariable("recording_id", recording_id);
recording_name = recording_prefix..recording_id.."."..record_ext;
recording_filename = recording_prefix..recording_id.."."..record_ext;
elseif (tonumber(recording_id) ~= nil) then
recording_name = recording_prefix..recording_id.."."..record_ext;
recording_filename = recording_prefix..recording_id.."."..record_ext;
else
recording_name = recording_prefix.."."..record_ext;
recording_filename = recording_prefix.."."..record_ext;
end
--set the default recording name if one was not provided
@ -128,7 +128,7 @@
--recording name is provided do nothing
else
--set a default recording_name
recording_name = "temp_"..session:get_uuid().."."..record_ext;
recording_name = recording_filename;
end
--prompt for the recording
@ -145,21 +145,21 @@
--record the file to the file system
-- syntax is session:recordFile(file_name, max_len_secs, silence_threshold, silence_secs);
session:execute("record", recordings_dir .."/".. recording_name);
session:execute("record", recordings_dir .."/".. recording_filename);
--show the storage type
freeswitch.consoleLog("notice", "[recordings] ".. storage_type .. "\n");
--read file content as base64 string
recording_base64 = assert(file.read_base64(recordings_dir .. "/" .. recording_name));
recording_base64 = assert(file.read_base64(recordings_dir .. "/" .. recording_filename));
elseif (storage_type == "http_cache") then
freeswitch.consoleLog("notice", "[recordings] ".. storage_type .. " ".. storage_path .."\n");
session:execute("record", storage_path .."/"..recording_name);
session:execute("record", storage_path .."/"..recording_filename);
else
freeswitch.consoleLog("notice", "[recordings] ".. storage_type .. " ".. recordings_dir .."\n");
-- record,Record File,<path> [<time_limit_secs>] [<silence_thresh>] [<silence_hits>]
session:execute("record", "'"..recordings_dir.."/"..recording_name.."' "..time_limit_secs.." "..silence_thresh.." "..silence_hits);
session:execute("record", "'"..recordings_dir.."/"..recording_filename.."' "..time_limit_secs.." "..silence_thresh.." "..silence_hits);
end
--setup the database connection
@ -167,18 +167,23 @@
local db = dbh or Database.new('system');
--get the description of the previous recording
sql = "SELECT recording_description FROM v_recordings ";
sql = "SELECT recording_description, recording_name ";
sql = sql .. " FROM v_recordings ";
sql = sql .. "where domain_uuid = :domain_uuid ";
sql = sql .. "and recording_filename = :recording_name ";
sql = sql .. "and recording_filename = :recording_filename ";
sql = sql .. "limit 1";
local params = {domain_uuid = domain_uuid, recording_name = recording_name};
local recording_description = db:first_value(sql, params) or ''
local params = {domain_uuid = domain_uuid, recording_filename = recording_filename};
local row = db:first_row(sql, params);
if (row) then
recording_description = row.recording_description;
recording_name = row.recording_name;
end
--delete the previous recording
sql = "delete from v_recordings ";
sql = sql .. "where domain_uuid = :domain_uuid ";
sql = sql .. "and recording_filename = :recording_name";
db:query(sql, {domain_uuid = domain_uuid, recording_name = recording_name});
sql = sql .. "and recording_filename = :recording_filename";
db:query(sql, {domain_uuid = domain_uuid, recording_filename = recording_filename});
--get a new uuid
recording_uuid = api:execute("create_uuid");
@ -200,7 +205,7 @@
table.insert(array, "( ");
table.insert(array, ":recording_uuid, ");
table.insert(array, ":domain_uuid, ");
table.insert(array, ":recording_name, ");
table.insert(array, ":recording_filename, ");
table.insert(array, ":recording_description, ");
if (storage_type == "base64") then
table.insert(array, ":recording_base64, ");
@ -212,6 +217,7 @@
local params = {
recording_uuid = recording_uuid;
domain_uuid = domain_uuid;
recording_filename = recording_filename;
recording_name = recording_name;
recording_description = recording_description;
recording_base64 = recording_base64;
@ -234,7 +240,7 @@
end
--preview the recording
session:streamFile(recordings_dir.."/"..recording_name);
session:streamFile(recordings_dir.."/"..recording_filename);
--approve the recording, to save the recording press 1 to re-record press 2
min_digits="0" max_digits="1" max_tries = "1"; digit_timeout = "100";
@ -270,8 +276,10 @@
session:streamFile("voicemail/vm-saved.wav");
return;
elseif (digits == "2") then
--reset the digit timeout
digit_timeout = "3000";
--delete the old recording
os.remove (recordings_dir.."/"..recording_name);
os.remove (recordings_dir.."/"..recording_filename);
--session:execute("system", "rm "..);
--make a new recording
begin_record(session, sounds_dir, recordings_dir);