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
This commit is contained in:
chansizzle 2025-03-12 17:39:05 -06:00 committed by GitHub
parent 31a88e3a15
commit 95761621a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 15 deletions

View File

@ -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);

View File

@ -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'] = "<html>\n";
$array['email_templates'][$x]['template_body'] .= "<body>\n";
$array['email_templates'][$x]['template_body'] .= "From \${caller_id_name} <a href=\"tel:\${caller_id_number}\">\${caller_id_number}</a><br />\n";
$array['email_templates'][$x]['template_body'] .= "<strong>From:</strong> \${caller_id_name} <a href=\"tel:\${caller_id_number}\">\${caller_id_number}</a><br />\n";
$array['email_templates'][$x]['template_body'] .= "<br />\n";
$array['email_templates'][$x]['template_body'] .= "Emergency Name \${emergency_caller_id_name}<br />\n";
$array['email_templates'][$x]['template_body'] .= "Emergency Name \${emergency_caller_id_number}<br />\n";
$array['email_templates'][$x]['template_body'] .= "Received \${message_date}<br />\n";
$array['email_templates'][$x]['template_body'] .= "Event \${event}<br />\n";
$array['email_templates'][$x]['template_body'] .= "<strong>Emergency Name:</strong> \${emergency_caller_id_name}<br />\n";
$array['email_templates'][$x]['template_body'] .= "<strong>Emergency Number:</strong> \${emergency_caller_id_number}<br />\n";
$array['email_templates'][$x]['template_body'] .= "<strong>Received:</strong> \${message_date}<br />\n";
$array['email_templates'][$x]['template_body'] .= "<strong>Event:</strong> \${event}<br />\n";
$array['email_templates'][$x]['template_body'] .= "</body>\n";
$array['email_templates'][$x]['template_body'] .= "</html>\n";
$array['email_templates'][$x]['template_type'] = 'html';
@ -530,15 +530,15 @@
$array['email_templates'][$x]['template_language'] = 'en-us';
$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'] = "<html>\n";
$array['email_templates'][$x]['template_body'] .= "<body>\n";
$array['email_templates'][$x]['template_body'] .= "From \${caller_id_name} <a href=\"tel:\${caller_id_number}\">\${caller_id_number}</a><br />\n";
$array['email_templates'][$x]['template_body'] .= "<strong>From:</strong> \${caller_id_name} <a href=\"tel:\${caller_id_number}\">\${caller_id_number}</a><br />\n";
$array['email_templates'][$x]['template_body'] .= "<br />\n";
$array['email_templates'][$x]['template_body'] .= "Emergency Name \${emergency_caller_id_name}<br />\n";
$array['email_templates'][$x]['template_body'] .= "Emergency Name \${emergency_caller_id_number}<br />\n";
$array['email_templates'][$x]['template_body'] .= "Received \${message_date}<br />\n";
$array['email_templates'][$x]['template_body'] .= "Event \${event}<br />\n";
$array['email_templates'][$x]['template_body'] .= "<strong>Emergency Name:</strong> \${emergency_caller_id_name}<br />\n";
$array['email_templates'][$x]['template_body'] .= "<strong>Emergency Number:</strong> \${emergency_caller_id_number}<br />\n";
$array['email_templates'][$x]['template_body'] .= "<strong>Received:</strong> \${message_date}<br />\n";
$array['email_templates'][$x]['template_body'] .= "<strong>Event:</strong> \${event}<br />\n";
$array['email_templates'][$x]['template_body'] .= "</body>\n";
$array['email_templates'][$x]['template_body'] .= "</html>\n";
$array['email_templates'][$x]['template_type'] = 'html';