Improve email subject for traffic and vs reports (#7969)

This commit is contained in:
Alfredo Cardigliano 2023-11-02 16:07:03 +01:00
parent 6f309a4a0f
commit f903a44771
3 changed files with 39 additions and 7 deletions

View file

@ -513,6 +513,33 @@ end
-- ######################################################
local function format_notification_subject(notifications)
if not notifications or #notifications < 1 then
subject = ""
else
local notification = notifications[1]
if notification.notification_type == "reports" then
subject = i18n("report.traffic_report")
elseif notification.notification_type == "vulnerability_scans" then
subject = i18n("vulnerability_scan.report")
else
local subject = i18n("alert_messages.alert")
if #notifications > 1 then
subject = i18n("alert_messages.x_alerts", {num=#notifications})
end
end
end
return subject
end
-- ######################################################
-- This is a basic function used to format notifications
local function format_notification(notification, options)
local message = notification.message or ""
@ -521,14 +548,14 @@ local function format_notification(notification, options)
if notification.notification_type == "reports" and
(not options or not options.nohtml) then
message = format_report_email(notification)
end
if (notification.notification_type == "vulnerability_scans") then
elseif (notification.notification_type == "vulnerability_scans") then
if(not options or not options.nohtml) then
-- nothing to do
else
message = format_no_html_vs_report_message(message)
end
end
return message
@ -536,6 +563,12 @@ end
-- ######################################################
function format_utils.formatSubject(notifications)
return format_notification_subject(notifications)
end
-- ######################################################
-- This function is used to format alerts/message from recipients
-- so it's going to convert a table into a message delivered to the
-- various recipients.