From 443812cb86c47370c557493b808cb4626fb065dc Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Thu, 31 Mar 2022 19:55:44 -0600 Subject: [PATCH] New code here needs more testing. Removing this code for now to keep it stable. --- .../app/fax/resources/scripts/hangup_rx.lua | 163 ------------------ 1 file changed, 163 deletions(-) diff --git a/app/scripts/resources/scripts/app/fax/resources/scripts/hangup_rx.lua b/app/scripts/resources/scripts/app/fax/resources/scripts/hangup_rx.lua index 511e26238e..21eeaf9be2 100644 --- a/app/scripts/resources/scripts/app/fax/resources/scripts/hangup_rx.lua +++ b/app/scripts/resources/scripts/app/fax/resources/scripts/hangup_rx.lua @@ -431,169 +431,6 @@ end end ---settings - require "resources.functions.settings"; - settings = settings(domain_uuid); - storage_type = ""; - storage_path = ""; - if (settings['fax'] ~= nil) then - if (settings['fax']['storage_type'] ~= nil) then - if (settings['fax']['storage_type']['text'] ~= nil) then - storage_type = settings['fax']['storage_type']['text']; - end - end - if (settings['fax']['storage_path'] ~= nil) then - if (settings['fax']['storage_path']['text'] ~= nil) then - storage_path = settings['fax']['storage_path']['text']; - storage_path = storage_path:gsub("${domain_name}", domain_name); - storage_path = storage_path:gsub("${voicemail_id}", voicemail_id); - storage_path = storage_path:gsub("${voicemail_dir}", voicemail_dir); - end - end - ignore_early_media = "false"; - if (settings['fax']['variable'] ~= nil) then - for i, var in ipairs(settings.fax.variable) do - --freeswitch.consoleLog("notice", "variable #" .. i .. ": " .. var .. "\n"); - if (var == "ignore_early_media=true") then - ignore_early_media = "true"; - end - end - end - end - ---fax busy - if (fax_result_code == "2" or fax_result_code == "3" or hangup_cause_q850 == 17) then - --do nothing. don't want to increment - freeswitch.consoleLog("INFO","[FAX] Last Fax was probably Busy, don't increment retry_attempts. \n"); - fax_busy_attempts = fax_busy_attempts + 1; - if (fax_busy_attempts > fax_busy_limit) then - fax_retry_attempts = 17; - else - freeswitch.msleep(fax_retry_sleep * 1000); - end - end - ---for email - email_address = env:getHeader("mailto_address"); - --email_address = api:execute("system", "/bin/echo -n "..email_address.." | /bin/sed -e s/\,/\\\\,/g"); - if (email_address == nil) then - email_address = ''; - else - email_address = email_address:gsub(",", "\\,"); - end - from_address = env:getHeader("mailfrom_address"); - if (from_address == nil) then - from_address = email_address; - end - uri_array = explode("/",fax_uri); - number_dialed = uri_array[4]; - if (number_dialed == nil) then - number_dialed = uri_array[3]; - if (number_dialed == nil) then - number_dialed = '0'; - end - end - --do not use apostrophies in message, they are not escaped and the mail will fail. - ---get the from address - if (from_address == nil) then - if (settings['fax'] ~= nil) then - if (settings['fax']['smtp_from'] ~= nil) then - if (settings['fax']['smtp_from']['text'] ~= nil) then - smtp_from = settings['fax']['smtp_from']['text']; - end - end - end - if (from_address == nil) then - if (settings['email'] ~= nil) then - if (settings['email']['smtp_from'] ~= nil) then - if (settings['email']['smtp_from']['text'] ~= nil) then - smtp_from = settings['email']['smtp_from']['text']; - end - end - end - end - end - ---get the templates - local sql = "SELECT * FROM v_email_templates "; - sql = sql .. "WHERE (domain_uuid = :domain_uuid or domain_uuid is null) "; - sql = sql .. "AND template_language = :template_language "; - sql = sql .. "AND template_category = 'fax' " - sql = sql .. "AND ( "; - sql = sql .. " template_subcategory = 'success_default' "; - --sql = sql .. " OR template_subcategory = 'fail_default' "; - --sql = sql .. " OR template_subcategory = 'fail_busy' "; - --sql = sql .. " OR template_subcategory = 'fail_invalid' "; - sql = sql .. ") " - sql = sql .. "AND template_enabled = 'true' " - local params = {domain_uuid = domain_uuid, template_language = default_language.."-"..default_dialect}; - if (debug["sql"]) then - freeswitch.consoleLog("notice", "[fax] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n"); - end - dbh:query(sql, params, function(row) - if (row["template_subcategory"] == 'success_default') then - email_subject_success_default = row["template_subject"]; - email_body_success_default = row["template_body"]; - - email_subject_fail_default = email_subject_success_default:gsub("${number_dialed}", number_dialed); - email_subject_fail_default = email_subject_success_default:gsub("${fax_busy_attempts}", fax_busy_attempts); - email_body_success_default = email_body_success_default:gsub("${number_dialed}", number_dialed); - email_body_success_default = email_body_success_default:gsub("${fax_busy_attempts}", fax_busy_attempts); - end - --if (row["template_subcategory"] == 'fail_default') then - -- email_subject_fail_default = row["template_subject"]; - -- email_body_fail_default = row["template_body"]; - - -- email_subject_fail_default = email_subject_fail_default:gsub("${number_dialed}", number_dialed); - -- email_subject_fail_default = email_subject_fail_default:gsub("${fax_busy_attempts}", fax_busy_attempts); - -- email_body_fail_default = email_body_fail_default:gsub("${number_dialed}", number_dialed); - -- email_body_fail_default = email_body_fail_default:gsub("${fax_busy_attempts}", fax_busy_attempts); - --end - --if (row["template_subcategory"] == 'fail_busy') then - -- email_subject_fail_busy = row["template_subject"]; - -- email_body_fail_busy = row["template_body"]; - - -- email_subject_fail_busy = email_subject_fail_busy:gsub("${number_dialed}", number_dialed); - -- email_subject_fail_busy = email_subject_fail_busy:gsub("${fax_busy_attempts}", fax_busy_attempts); - -- email_body_fail_busy = email_body_fail_busy:gsub("${number_dialed}", number_dialed); - -- email_body_fail_busy = email_body_fail_busy:gsub("${fax_busy_attempts}", fax_busy_attempts); - --end - --if (row["template_subcategory"] == 'fail_invalid') then - -- email_subject_fail_invalid = row["template_subject"]; - -- email_body_fail_invalid = row["template_body"]; - - -- email_subject_fail_invalid = email_subject_fail_invalid:gsub("${number_dialed}", number_dialed); - -- email_subject_fail_invalid = email_subject_fail_invalid:gsub("${fax_busy_attempts}", fax_busy_attempts); - -- email_body_fail_invalid = email_body_fail_invalid:gsub("${number_dialed}", number_dialed); - -- email_body_fail_invalid = email_body_fail_invalid:gsub("${fax_busy_attempts}", fax_busy_attempts); - --end - end); - ---mark the fax as sent - if (fax_success == '1') then - sql = "update v_fax_queue "; - sql = sql .. "set fax_status = 'sent' "; - sql = sql .. "where fax_queue_uuid = :fax_queue_uuid "; - local params = {fax_queue_uuid = fax_queue_uuid} - dbh:query(sql, params); - end - ---prepare the headers - headers = {} - headers["X-FusionPBX-Domain-UUID"] = domain_uuid; - headers["X-FusionPBX-Domain-Name"] = domain_name; - headers["X-FusionPBX-Email-From"] = from_address; - headers["X-FusionPBX-Call-UUID"] = uuid; - ---send the email - send_mail(headers, - from_address, - email_address, - {email_subject, email_body}, - fax_file:gsub(".tif",".pdf") - ); - --send the selected variables to the console if (fax_success ~= nil) then freeswitch.consoleLog("INFO","fax_success: '" .. fax_success .. "'\n");