From 1451d2984cb1942ae10fd08f5af368c55349d84a Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Thu, 16 Apr 2015 14:47:21 +0000 Subject: [PATCH] Add record in recordings table no matter what type of storage type is used. --- resources/install/scripts/recordings.lua | 93 ++++++++++++------------ 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/resources/install/scripts/recordings.lua b/resources/install/scripts/recordings.lua index a1896b25e6..b5b858bf18 100644 --- a/resources/install/scripts/recordings.lua +++ b/resources/install/scripts/recordings.lua @@ -139,52 +139,6 @@ f:close(); recording_base64 = base64.encode(file_content); - --delete the previous recording - sql = "delete from v_recordings "; - sql = sql .. "where domain_uuid = '".. domain_uuid .. "' "; - sql = sql .. "and recording_name = '".. recording_name .."'"; - dbh:query(sql); - - --get a new uuid - recording_uuid = api:execute("create_uuid"); - - --save the message to the voicemail messages - local array = {} - table.insert(array, "INSERT INTO v_recordings "); - table.insert(array, "("); - table.insert(array, "recording_uuid, "); - table.insert(array, "domain_uuid, "); - table.insert(array, "recording_filename, "); - if (storage_type == "base64") then - table.insert(array, "recording_base64, "); - end - table.insert(array, "recording_name "); - table.insert(array, ") "); - table.insert(array, "VALUES "); - table.insert(array, "( "); - table.insert(array, "'"..recording_uuid.."', "); - table.insert(array, "'"..domain_uuid.."', "); - table.insert(array, "'"..recording_name.."', "); - if (storage_type == "base64") then - table.insert(array, "'"..recording_base64.."', "); - end - table.insert(array, "'"..recording_name.."' "); - table.insert(array, ") "); - sql = table.concat(array, "\n"); - if (debug["sql"]) then - freeswitch.consoleLog("notice", "[recording] SQL: " .. sql .. "\n"); - end - if (storage_type == "base64") then - array = explode("://", database["system"]); - local luasql = require "luasql.postgres"; - local env = assert (luasql.postgres()); - local dbh = env:connect(array[2]); - res, serr = dbh:execute(sql); - dbh:close(); - env:close(); - else - dbh:query(sql); - end elseif (storage_type == "http_cache") then freeswitch.consoleLog("notice", "[recordings] ".. storage_type .. " ".. storage_path .."\n"); session:execute("record", storage_path .."/"..recording_name); @@ -193,6 +147,53 @@ session:execute("record", "'"..recordings_dir.."/"..recording_name.."' 10800 500 500"); end + --delete the previous recording + sql = "delete from v_recordings "; + sql = sql .. "where domain_uuid = '".. domain_uuid .. "' "; + sql = sql .. "and recording_name = '".. recording_name .."'"; + dbh:query(sql); + + --get a new uuid + recording_uuid = api:execute("create_uuid"); + + --save the message to the voicemail messages + local array = {} + table.insert(array, "INSERT INTO v_recordings "); + table.insert(array, "("); + table.insert(array, "recording_uuid, "); + table.insert(array, "domain_uuid, "); + table.insert(array, "recording_filename, "); + if (storage_type == "base64") then + table.insert(array, "recording_base64, "); + end + table.insert(array, "recording_name "); + table.insert(array, ") "); + table.insert(array, "VALUES "); + table.insert(array, "( "); + table.insert(array, "'"..recording_uuid.."', "); + table.insert(array, "'"..domain_uuid.."', "); + table.insert(array, "'"..recording_name.."', "); + if (storage_type == "base64") then + table.insert(array, "'"..recording_base64.."', "); + end + table.insert(array, "'"..recording_name.."' "); + table.insert(array, ") "); + sql = table.concat(array, "\n"); + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[recording] SQL: " .. sql .. "\n"); + end + if (storage_type == "base64") then + array = explode("://", database["system"]); + local luasql = require "luasql.postgres"; + local env = assert (luasql.postgres()); + local dbh = env:connect(array[2]); + res, serr = dbh:execute(sql); + dbh:close(); + env:close(); + else + dbh:query(sql); + end + --preview the recording session:streamFile(recordings_dir.."/"..recording_name);