From 53b9bb638c42c94e4db3fa359a163bd2e17581a1 Mon Sep 17 00:00:00 2001 From: Michael Derynck Date: Tue, 30 Aug 2022 15:29:10 -0600 Subject: [PATCH] Check if notification policies is empty --- engine/apps/alerts/tasks/notify_group.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/engine/apps/alerts/tasks/notify_group.py b/engine/apps/alerts/tasks/notify_group.py index 0a748c33..a3de0b9f 100644 --- a/engine/apps/alerts/tasks/notify_group.py +++ b/engine/apps/alerts/tasks/notify_group.py @@ -63,13 +63,15 @@ def notify_group_task(alert_group_pk, escalation_policy_snapshot_order=None): important=escalation_policy_step == EscalationPolicy.STEP_NOTIFY_GROUP_IMPORTANT, ) - notification_channels = [] - if notification_policies.filter(step=UserNotificationPolicy.Step.NOTIFY).count() == 0: - usergroup_notification_plan += "Empty notifications" - else: + if notification_policies: usergroup_notification_plan += "\n_{} (".format( step.get_user_notification_message_for_thread_for_usergroup(user, notification_policies.first()) ) + + notification_channels = [] + if notification_policies.filter(step=UserNotificationPolicy.Step.NOTIFY).count() == 0: + usergroup_notification_plan += "Empty notifications" + for notification_policy in notification_policies: if notification_policy.step == UserNotificationPolicy.Step.NOTIFY: notification_channels.append(