Add. `Tasks.send_mail_task` function to send task reply.
This commit is contained in:
parent
e7ee8fb0f8
commit
f8c86b42bc
|
|
@ -4,7 +4,6 @@ require "resources.functions.sleep"
|
|||
local log = require "resources.functions.log".next_fax_task
|
||||
local Tasks = require "app.fax.resources.scripts.queue.tasks"
|
||||
local Esl = require "resources.functions.esl"
|
||||
local send_mail = require "resources.functions.send_mail"
|
||||
|
||||
local FAX_OPTIONS = {
|
||||
"fax_use_ecm=false,fax_enable_t38=true,fax_enable_t38_request=true,fax_disable_v17=default";
|
||||
|
|
@ -15,22 +14,16 @@ local FAX_OPTIONS = {
|
|||
}
|
||||
|
||||
local function task_send_mail(task)
|
||||
local mail_x_headers = {
|
||||
["X-FusionPBX-Domain-UUID"] = task.domain_uuid;
|
||||
["X-FusionPBX-Domain-Name"] = task.domain_name;
|
||||
["X-FusionPBX-Email-Type"] = 'email2fax';
|
||||
}
|
||||
local number_dialed = task.uri:match("/([^/]-)%s*$")
|
||||
if task.reply_address and #task.reply_address > 0 then
|
||||
send_mail(mail_x_headers, task.reply_address, {
|
||||
"Fax to: " .. number_dialed .. " FAILED",
|
||||
table.concat{
|
||||
"We are sorry the fax failed to go through. ",
|
||||
"It has been attached. Please check the number "..number_dialed..", ",
|
||||
"and if it was correct you might consider emailing it instead.",
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
Tasks.send_mail_task(task, {
|
||||
"Fax to: " .. number_dialed .. " FAILED",
|
||||
table.concat{
|
||||
"We are sorry the fax failed to go through. ",
|
||||
"It has been attached. Please check the number " .. number_dialed .. ", ",
|
||||
"and if it was correct you might consider emailing it instead.",
|
||||
}}
|
||||
)
|
||||
end
|
||||
|
||||
local function next_task()
|
||||
|
|
|
|||
|
|
@ -244,14 +244,6 @@
|
|||
dbh:query(sql);
|
||||
end
|
||||
|
||||
--prepare the headers
|
||||
local mail_x_headers = {
|
||||
["X-FusionPBX-Domain-UUID"] = domain_uuid;
|
||||
["X-FusionPBX-Domain-Name"] = domain_name;
|
||||
["X-FusionPBX-Call-UUID"] = uuid;
|
||||
["X-FusionPBX-Email-Type"] = 'email2fax';
|
||||
}
|
||||
|
||||
-- add the fax files
|
||||
if fax_success == "1" then
|
||||
|
||||
|
|
@ -331,16 +323,13 @@
|
|||
end
|
||||
|
||||
Tasks.remove_task(task)
|
||||
|
||||
if task.reply_address and #task.reply_address > 0 then
|
||||
send_mail(mail_x_headers, task.reply_address, {
|
||||
"Fax to: " .. number_dialed .. " SENT",
|
||||
table.concat{
|
||||
"We are happy to report the fax was sent successfully.",
|
||||
"It has been attached for your records.",
|
||||
}
|
||||
})
|
||||
end
|
||||
Tasks.send_mail_task(task, {
|
||||
"Fax to: " .. number_dialed .. " SENT",
|
||||
table.concat{
|
||||
"We are happy to report the fax was sent successfully.",
|
||||
"It has been attached for your records.",
|
||||
}}, uuid
|
||||
)
|
||||
end
|
||||
|
||||
if fax_success ~= "1" then
|
||||
|
|
@ -362,16 +351,14 @@
|
|||
Tasks.wait_task(task, answered, hangup_cause_q850)
|
||||
if task.status ~= 0 then
|
||||
Tasks.remove_task(task)
|
||||
if task.reply_address and #task.reply_address > 0 then
|
||||
send_mail(mail_x_headers, task.reply_address, {
|
||||
"Fax to: " .. number_dialed .. " FAILED",
|
||||
table.concat{
|
||||
"We are sorry the fax failed to go through. ",
|
||||
"It has been attached. Please check the number "..number_dialed..", ",
|
||||
"and if it was correct you might consider emailing it instead.",
|
||||
}
|
||||
})
|
||||
end
|
||||
Tasks.send_mail_task(task, {
|
||||
"Fax to: " .. number_dialed .. " FAILED",
|
||||
table.concat{
|
||||
"We are sorry the fax failed to go through. ",
|
||||
"It has been attached. Please check the number "..number_dialed..", ",
|
||||
"and if it was correct you might consider emailing it instead.",
|
||||
}}, uuid
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
local Database = require "resources.functions.database"
|
||||
local Settings = require "resources.functions.lazy_settings"
|
||||
local Database = require "resources.functions.database"
|
||||
local Settings = require "resources.functions.lazy_settings"
|
||||
local send_mail = require "resources.functions.send_mail"
|
||||
|
||||
local db
|
||||
|
||||
|
|
@ -244,6 +245,21 @@ local function cleanup_tasks()
|
|||
db:query(remove_finished_tasks_sql)
|
||||
end
|
||||
|
||||
local function send_mail_task(task, message, call_uuid)
|
||||
if not task.reply_address or #task.reply_address == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local mail_x_headers = {
|
||||
["X-FusionPBX-Domain-UUID"] = task.domain_uuid;
|
||||
["X-FusionPBX-Domain-Name"] = task.domain_name;
|
||||
["X-FusionPBX-Call-UUID"] = call_uuid;
|
||||
["X-FusionPBX-Email-Type"] = 'email2fax';
|
||||
}
|
||||
|
||||
return send_mail(mail_x_headers, task.reply_address, message)
|
||||
end
|
||||
|
||||
return {
|
||||
release_db = function()
|
||||
if db then
|
||||
|
|
@ -251,10 +267,11 @@ return {
|
|||
db = nil
|
||||
end
|
||||
end;
|
||||
next_task = next_task;
|
||||
wait_task = wait_task;
|
||||
select_task = select_task;
|
||||
remove_task = remove_task;
|
||||
release_task = release_task;
|
||||
cleanup_tasks = cleanup_tasks;
|
||||
next_task = next_task;
|
||||
wait_task = wait_task;
|
||||
select_task = select_task;
|
||||
remove_task = remove_task;
|
||||
release_task = release_task;
|
||||
cleanup_tasks = cleanup_tasks;
|
||||
send_mail_task = send_mail_task;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue