From 95761621a661b39eba26fcf8b7cb9fd62a33d815 Mon Sep 17 00:00:00 2001 From: chansizzle <14916599+chansizzle@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:39:05 -0600 Subject: [PATCH] improve emergency emailing (#7309) * improve emergency emailing 1. set emergency CID name & number to the outbound CID name & number if emergency CID name & number are not set 2. remove duplicate item in email body 3. change the hardcoded email subject '911 Emergency Call' to be dynamically provided from the event. I do not like seeing the subject '911 Emergency Call' when it is an TEST call. * improve emergency emailing 1. change the hardcoded email subject '911 Emergency Call' to be dynamically provided from the event. I do not like seeing the subject '911 Emergency Call' when it is an TEST call. 2. fix email template misspelling 3. improved email template with bold fonts --- .../resources/scripts/app/emergency/index.lua | 13 +++++++--- core/email_templates/app_defaults.php | 24 +++++++++---------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/app/switch/resources/scripts/app/emergency/index.lua b/app/switch/resources/scripts/app/emergency/index.lua index d33c5eb2a2..53c945a435 100644 --- a/app/switch/resources/scripts/app/emergency/index.lua +++ b/app/switch/resources/scripts/app/emergency/index.lua @@ -118,13 +118,18 @@ if (session and session:ready()) then sip_from_user = session:getVariable("sip_from_user"); emergency_caller_id_name = session:getVariable("emergency_caller_id_name"); emergency_caller_id_number = session:getVariable("emergency_caller_id_number"); + outbound_caller_id_name = session:getVariable("outbound_caller_id_name"); outbound_caller_id_number = session:getVariable("outbound_caller_id_number"); destination_number = session:getVariable("destination_number"); end --set the defaults -if (not emergency_caller_id_name) then emergency_caller_id_name = ''; end -if (not emergency_caller_id_number) then emergency_caller_id_number = '' end +if (not emergency_caller_id_name or emergency_caller_id_name == '') then + emergency_caller_id_name = outbound_caller_id_name +end +if (not emergency_caller_id_number or emergency_caller_id_number == '') then + emergency_caller_id_number = outbound_caller_id_number +end --no emergency emails found under domain, using default local sql = "SELECT default_setting_value "; @@ -181,6 +186,9 @@ end local t = dbh:first_row(sql); call_date = t.call_date; +-- replace the hardcoded template subject with the event +subject = event; + --send the email if (#to > 0) then --prepare the body @@ -190,7 +198,6 @@ if (#to > 0) then body = body:gsub("${emergency_caller_id_name}", emergency_caller_id_name); body = body:gsub("${emergency_caller_id_number}", emergency_caller_id_number); body = body:gsub("${sip_from_user}", sip_from_user); - body = body:gsub("${caller_id_number}", caller_id_number); body = body:gsub("${message_date}", call_date); body = body:gsub("${event}", event); body = trim(body); diff --git a/core/email_templates/app_defaults.php b/core/email_templates/app_defaults.php index de95aa70ab..f3280dd25d 100644 --- a/core/email_templates/app_defaults.php +++ b/core/email_templates/app_defaults.php @@ -510,15 +510,15 @@ $array['email_templates'][$x]['template_language'] = 'en-gb'; $array['email_templates'][$x]['template_category'] = 'plugin'; $array['email_templates'][$x]['template_subcategory'] = 'emergency'; - $array['email_templates'][$x]['template_subject'] = '911 Emergency Call'; + $array['email_templates'][$x]['template_subject'] = '\${event}'; $array['email_templates'][$x]['template_body'] = "\n"; $array['email_templates'][$x]['template_body'] .= "
\n"; - $array['email_templates'][$x]['template_body'] .= "From \${caller_id_name} \${caller_id_number}