diff --git a/resources/install/scripts/app/failure_handler/index.lua b/resources/install/scripts/app/failure_handler/index.lua index 9bfdca4179..4445d5600d 100644 --- a/resources/install/scripts/app/failure_handler/index.lua +++ b/resources/install/scripts/app/failure_handler/index.lua @@ -34,6 +34,9 @@ require "resources.functions.trim"; require "resources.functions.base64"; +--load libraries + require 'resources.functions.send_mail' + --check the missed calls function missed() if (missed_call_app ~= nil and missed_call_data ~= nil) then @@ -55,10 +58,12 @@ end --prepare the headers - headers = '{"X-FusionPBX-Domain-UUID":"'..domain_uuid..'",'; - headers = headers..'"X-FusionPBX-Domain-Name":"'..domain_name..'",'; - headers = headers..'"X-FusionPBX-Call-UUID":"'..uuid..'",'; - headers = headers..'"X-FusionPBX-Email-Type":"missed"}'; + local headers = { + ["X-FusionPBX-Domain-UUID"] = domain_uuid; + ["X-FusionPBX-Domain-Name"] = domain_name; + ["X-FusionPBX-Call-UUID"] = uuid; + ["X-FusionPBX-Email-Type"] = 'missed'; + } --prepare the subject local f = io.open(file_subject, "r"); @@ -88,13 +93,15 @@ body = body:gsub([["]], """); body = trim(body); - --send the email - cmd = "luarun email.lua "..missed_call_data.." "..missed_call_data.." "..headers.." '"..subject.."' '"..body.."'"; + --send the emails + send_mail(headers, + missed_call_data, + {subject, body} + ); + if (debug["info"]) then - freeswitch.consoleLog("notice", "[missed call] cmd: " .. cmd .. "\n"); + freeswitch.consoleLog("notice", "[missed call] " .. caller_id_number .. "->" .. sip_to_user .. "emailed to " .. missed_call_data .. "\n"); end - api = freeswitch.API(); - result = api:executeString(cmd); end end end diff --git a/resources/install/scripts/app/hangup/index.lua b/resources/install/scripts/app/hangup/index.lua index fa15e2f520..35b31534cd 100644 --- a/resources/install/scripts/app/hangup/index.lua +++ b/resources/install/scripts/app/hangup/index.lua @@ -31,6 +31,9 @@ require "resources.functions.base64"; require "resources.functions.file_exists"; +--load libraries + require 'resources.functions.send_mail' + --create the api object api = freeswitch.API(); @@ -55,10 +58,12 @@ end --prepare the headers - headers = '{"X-FusionPBX-Domain-UUID":"'..domain_uuid..'",'; - headers = headers..'"X-FusionPBX-Domain-Name":"'..domain_name..'",'; - headers = headers..'"X-FusionPBX-Call-UUID":"'..uuid..'",'; - headers = headers..'"X-FusionPBX-Email-Type":"missed"}'; + local headers = { + ["X-FusionPBX-Domain-UUID"] = domain_uuid; + ["X-FusionPBX-Domain-Name"] = domain_name; + ["X-FusionPBX-Call-UUID"] = uuid; + ["X-FusionPBX-Email-Type"] = 'missed'; + } --prepare the subject local f = io.open(file_subject, "r"); @@ -89,11 +94,14 @@ body = trim(body); --send the emails - cmd = "luarun email.lua "..missed_call_data.." "..missed_call_data.." "..headers.." '"..subject.."' '"..body.."'"; + send_mail(headers, + missed_call_data, + {subject, body} + ); + if (debug["info"]) then - freeswitch.consoleLog("notice", "[missed call] cmd: " .. cmd .. "\n"); + freeswitch.consoleLog("notice", "[missed call] " .. caller_id_number .. "->" .. sip_to_user .. "emailed to " .. missed_call_data .. "\n"); end - result = api:executeString(cmd); end end end