Handle recipient[recipient_minimum_severity] = nil (all categories)

This commit is contained in:
Alfredo Cardigliano 2020-11-12 10:04:14 +01:00
parent f65f4bbb1f
commit 5d606a41fc

View file

@ -104,7 +104,8 @@ function pools_alert_utils.get_entity_recipients_by_pool_id(entity_id, pool_id,
for _, recipient in pairs(entity_pool["recipients"]) do
local recipient_ok = false
if current_script and current_script.category and current_script.category.id then
if current_script and current_script.category and current_script.category.id and
recipient["recipient_user_script_categories"] ~= nil then
-- Make sure the user script category belongs to the recipient user script categories
for _, user_script_category in pairs(recipient["recipient_user_script_categories"]) do
if user_script_category == current_script.category.id then
@ -117,7 +118,8 @@ function pools_alert_utils.get_entity_recipients_by_pool_id(entity_id, pool_id,
end
if recipient_ok then
if alert_severity < recipient["recipient_minimum_severity"] then
if recipient["recipient_minimum_severity"] ~= nil and
alert_severity < recipient["recipient_minimum_severity"] then
-- If the current alert severity is less than the minimum requested severity
-- exclude the recipient
recipient_ok = false