Add fax to the add fax_files table if the file exists
This commit is contained in:
parent
c75e573e84
commit
bde4163c25
|
|
@ -48,6 +48,7 @@
|
||||||
require "resources.functions.explode";
|
require "resources.functions.explode";
|
||||||
require "resources.functions.count";
|
require "resources.functions.count";
|
||||||
require "resources.functions.send_mail";
|
require "resources.functions.send_mail";
|
||||||
|
require "resources.functions.file_exists";
|
||||||
|
|
||||||
--check if windows
|
--check if windows
|
||||||
local IS_WINDOWS = (package.config:sub(1,1) == '\\')
|
local IS_WINDOWS = (package.config:sub(1,1) == '\\')
|
||||||
|
|
@ -322,83 +323,81 @@
|
||||||
dbh:query(sql, params);
|
dbh:query(sql, params);
|
||||||
|
|
||||||
--add the fax files
|
--add the fax files
|
||||||
if (fax_success ~= nil) then
|
if (file_exists(fax_file)) then
|
||||||
if (fax_success =="1") then
|
if (storage_type == "base64") then
|
||||||
if (storage_type == "base64") then
|
--include the file io
|
||||||
--include the file io
|
local file = require "resources.functions.file"
|
||||||
local file = require "resources.functions.file"
|
|
||||||
|
|
||||||
--read file content as base64 string
|
--read file content as base64 string
|
||||||
fax_base64 = assert(file.read_base64(fax_file));
|
fax_base64 = assert(file.read_base64(fax_file));
|
||||||
end
|
end
|
||||||
|
|
||||||
local sql = {}
|
local sql = {}
|
||||||
table.insert(sql, "insert into v_fax_files ");
|
table.insert(sql, "insert into v_fax_files ");
|
||||||
table.insert(sql, "(");
|
table.insert(sql, "(");
|
||||||
table.insert(sql, "fax_file_uuid, ");
|
table.insert(sql, "fax_file_uuid, ");
|
||||||
table.insert(sql, "fax_uuid, ");
|
table.insert(sql, "fax_uuid, ");
|
||||||
table.insert(sql, "fax_mode, ");
|
table.insert(sql, "fax_mode, ");
|
||||||
table.insert(sql, "fax_file_type, ");
|
table.insert(sql, "fax_file_type, ");
|
||||||
table.insert(sql, "fax_file_path, ");
|
table.insert(sql, "fax_file_path, ");
|
||||||
if (caller_id_name ~= nil) then
|
if (caller_id_name ~= nil) then
|
||||||
table.insert(sql, "fax_caller_id_name, ");
|
table.insert(sql, "fax_caller_id_name, ");
|
||||||
end
|
end
|
||||||
if (caller_id_number ~= nil) then
|
if (caller_id_number ~= nil) then
|
||||||
table.insert(sql, "fax_caller_id_number, ");
|
table.insert(sql, "fax_caller_id_number, ");
|
||||||
end
|
end
|
||||||
table.insert(sql, "fax_date, ");
|
table.insert(sql, "fax_date, ");
|
||||||
table.insert(sql, "fax_epoch, ");
|
table.insert(sql, "fax_epoch, ");
|
||||||
if (storage_type == "base64") then
|
if (storage_type == "base64") then
|
||||||
table.insert(sql, "fax_base64, ");
|
table.insert(sql, "fax_base64, ");
|
||||||
end
|
end
|
||||||
table.insert(sql, "domain_uuid");
|
table.insert(sql, "domain_uuid");
|
||||||
table.insert(sql, ") ");
|
table.insert(sql, ") ");
|
||||||
table.insert(sql, "values ");
|
table.insert(sql, "values ");
|
||||||
table.insert(sql, "(");
|
table.insert(sql, "(");
|
||||||
table.insert(sql, ":uuid, ");
|
table.insert(sql, ":uuid, ");
|
||||||
table.insert(sql, ":fax_uuid, ");
|
table.insert(sql, ":fax_uuid, ");
|
||||||
table.insert(sql, "'rx', ");
|
table.insert(sql, "'rx', ");
|
||||||
table.insert(sql, "'tif', ");
|
table.insert(sql, "'tif', ");
|
||||||
table.insert(sql, ":fax_file, ");
|
table.insert(sql, ":fax_file, ");
|
||||||
if (caller_id_name ~= nil) then
|
if (caller_id_name ~= nil) then
|
||||||
table.insert(sql, ":caller_id_name, ");
|
table.insert(sql, ":caller_id_name, ");
|
||||||
end
|
end
|
||||||
if (caller_id_number ~= nil) then
|
if (caller_id_number ~= nil) then
|
||||||
table.insert(sql, ":caller_id_number, ");
|
table.insert(sql, ":caller_id_number, ");
|
||||||
end
|
end
|
||||||
if (database["type"] == "sqlite") then
|
if (database["type"] == "sqlite") then
|
||||||
table.insert(sql, ":fax_date, ");
|
table.insert(sql, ":fax_date, ");
|
||||||
else
|
else
|
||||||
table.insert(sql, "now(), ");
|
table.insert(sql, "now(), ");
|
||||||
end
|
end
|
||||||
table.insert(sql, ":fax_time, ");
|
table.insert(sql, ":fax_time, ");
|
||||||
if (storage_type == "base64") then
|
if (storage_type == "base64") then
|
||||||
table.insert(sql, ":fax_base64, ");
|
table.insert(sql, ":fax_base64, ");
|
||||||
end
|
end
|
||||||
table.insert(sql, ":domain_uuid");
|
table.insert(sql, ":domain_uuid");
|
||||||
table.insert(sql, ")");
|
table.insert(sql, ")");
|
||||||
sql = table.concat(sql, "\n");
|
sql = table.concat(sql, "\n");
|
||||||
local params = {
|
local params = {
|
||||||
uuid = uuid;
|
uuid = uuid;
|
||||||
domain_uuid = domain_uuid;
|
domain_uuid = domain_uuid;
|
||||||
fax_uuid = fax_uuid;
|
fax_uuid = fax_uuid;
|
||||||
fax_file = fax_file;
|
fax_file = fax_file;
|
||||||
caller_id_name = caller_id_name;
|
caller_id_name = caller_id_name;
|
||||||
caller_id_number = caller_id_number;
|
caller_id_number = caller_id_number;
|
||||||
fax_base64 = fax_base64;
|
fax_base64 = fax_base64;
|
||||||
fax_date = os.date("%Y-%m-%d %X");
|
fax_date = os.date("%Y-%m-%d %X");
|
||||||
fax_time = os.time();
|
fax_time = os.time();
|
||||||
};
|
};
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("notice", "[fax] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
freeswitch.consoleLog("notice", "[fax] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||||
end
|
end
|
||||||
if (storage_type == "base64") then
|
if (storage_type == "base64") then
|
||||||
local dbh = Database.new('system', 'base64');
|
local dbh = Database.new('system', 'base64');
|
||||||
dbh:query(sql, params);
|
dbh:query(sql, params);
|
||||||
dbh:release();
|
dbh:release();
|
||||||
else
|
else
|
||||||
result = dbh:query(sql, params);
|
result = dbh:query(sql, params);
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue