Merge pull request #1534 from moteus/fax_send_pdf

Fix. send fax file as PDF in response message
This commit is contained in:
FusionPBX 2016-04-06 01:47:18 -06:00
commit 87adfbae24
1 changed files with 12 additions and 3 deletions

View File

@ -75,6 +75,7 @@
local fax_file = env:getHeader("fax_file") or task.fax_file
local wav_file = env:getHeader("wav_file") or task.wav_file
local fax_uuid = task.fax_uuid
local pdf_file = fax_file and string.gsub(fax_file, '(%.[^\\/]+)$', '.pdf')
-- Email variables
local number_dialed = fax_uri:match("/([^/]-)%s*$")
@ -169,7 +170,7 @@
--settings
local settings = Settings.new(dbh, domain_name, domain_uuid)
local keep_local = settings:get('fax', 'keep_local','boolean')
local keep_local = settings:get('fax', 'keep_local', 'boolean')
local storage_type = (keep_local == "false") and "" or settings:get('fax', 'storage_type', 'text')
local function opt(v, default)
@ -336,9 +337,11 @@
subject = "Fax to: " .. number_dialed .. " SENT"
end
Tasks.send_mail_task(task, {subject, body}, uuid, file_exists(fax_file))
local attachment = pdf_file and file_exists(pdf_file) or fax_file and file_exists(fax_file)
Tasks.send_mail_task(task, {subject, body}, uuid, attachment)
if keep_local == "false" then
os.remove(pdf_file);
os.remove(fax_file);
end
end
@ -386,7 +389,13 @@
subject = "Fax to: " .. number_dialed .. " FAILED"
end
Tasks.send_mail_task(task, {subject, body}, uuid, file_exists(fax_file))
local attachment = pdf_file and file_exists(pdf_file) or fax_file and file_exists(fax_file)
Tasks.send_mail_task(task, {subject, body}, uuid, attachment)
if keep_local == "false" then
os.remove(pdf_file);
os.remove(fax_file);
end
end
end