From 269c21d37b8384e7824ae4610581d87e105fe942 Mon Sep 17 00:00:00 2001 From: Mafoo Date: Tue, 8 Sep 2020 16:46:52 +0100 Subject: [PATCH] BugFix [master] - ring_groups\index.lua (#5441) change to use functions.send_mail so system from address is taken into account --- .../scripts/app/ring_groups/index.lua | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/app/scripts/resources/scripts/app/ring_groups/index.lua b/app/scripts/resources/scripts/app/ring_groups/index.lua index e8977d1300..f1d2610981 100644 --- a/app/scripts/resources/scripts/app/ring_groups/index.lua +++ b/app/scripts/resources/scripts/app/ring_groups/index.lua @@ -35,7 +35,6 @@ dbh = Database.new('system'); --include json library - --debug["sql"] = true; local json if (debug["sql"]) then json = require "resources.functions.lunajson" @@ -52,6 +51,7 @@ --- include libs local route_to_bridge = require "resources.functions.route_to_bridge" local play_file = require "resources.functions.play_file" + local send_mail = require 'resources.functions.send_mail' --define the session hangup function session_hangup_hook() @@ -294,6 +294,9 @@ --send missed call email if (missed_call_app ~= nil and missed_call_data ~= nil) then if (missed_call_app == "email") then + --prepare the email address + mail_to = missed_call_data; + --set the sounds path for the language, dialect and voice default_language = session:getVariable("default_language"); default_dialect = session:getVariable("default_dialect"); @@ -319,10 +322,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 subject = subject:gsub("${caller_id_name}", caller_id_name); @@ -349,14 +354,16 @@ body = body:gsub("'", "'"); body = body:gsub([["]], """); body = trim(body); - + --send the email - cmd = "luarun email.lua "..missed_call_data.." "..missed_call_data.." "..headers.." '"..subject.."' '"..body.."'"; if (debug["info"]) then - freeswitch.consoleLog("notice", "[missed call] cmd: " .. cmd .. "\n"); + freeswitch.consoleLog("notice", "[missed call]: "..mail_to.." '"..subject.."' '"..body.."'\n"); end - api = freeswitch.API(); - result = api:executeString(cmd); + + send_mail(headers, + mail_to, + {subject, body} + ); end end end