Fix. Send mail when fail create outbound channel.
This commit is contained in:
parent
c9be5948c0
commit
aec2777f62
|
|
@ -4,6 +4,7 @@ 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";
|
||||
|
|
@ -13,6 +14,25 @@ local FAX_OPTIONS = {
|
|||
"fax_use_ecm=false,fax_enable_t38=false,fax_enable_t38_request=false,fax_disable_v17=false";
|
||||
}
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
local function next_task()
|
||||
local task, err = Tasks.next_task()
|
||||
|
||||
|
|
@ -43,6 +63,7 @@ local function next_task()
|
|||
Tasks.wait_task(task, false, info)
|
||||
if task.status ~= 0 then
|
||||
Tasks.remove_task(task)
|
||||
task_send_mail(task)
|
||||
end
|
||||
log.noticef('Can not originate to `%s` cause: %s: %s ', task.uri, tostring(status), tostring(info))
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in New Issue