SIENTIAPDE-1172
feat: enhance notification handling in Formatters and SlotManager classes - Introduced a mechanism to prevent duplicate notifications by tracking already added keys. - Updated notification filtering logic to ensure unique notifications are processed for each receiver group. - Improved overall notification management in orchestrator activities.
This commit is contained in:
@@ -558,15 +558,20 @@ class Formatters(BaseActivity):
|
||||
}
|
||||
receiver_groups[group_name]['notifications'] = []
|
||||
|
||||
already_added_keys = []
|
||||
|
||||
ignore_list = receiver_group.get('ignore', [])
|
||||
|
||||
for notification in notification_package:
|
||||
alert_type = "reports"
|
||||
notification_id = notification['notification_id']
|
||||
|
||||
key = f"{notification['trigger']}:{notification_id}"
|
||||
|
||||
# Check if this group must be notified
|
||||
if alert_type in receiver_group['contents'] and notification_id not in ignore_list:
|
||||
if alert_type in receiver_group['contents'] and notification_id not in ignore_list and key not in already_added_keys:
|
||||
receiver_groups[group_name]["notifications"].append(
|
||||
notification)
|
||||
already_added_keys.append(key)
|
||||
|
||||
return receiver_groups
|
||||
|
||||
@@ -289,6 +289,8 @@ class SlotManager(Redis):
|
||||
}
|
||||
receiver_groups[group_name]['notifications'] = []
|
||||
|
||||
already_added_keys = []
|
||||
|
||||
ignore_list = receiver_group.get('ignore', [])
|
||||
|
||||
for notification in notification_package:
|
||||
@@ -311,9 +313,10 @@ class SlotManager(Redis):
|
||||
alert_type = "persistent_alerts"
|
||||
|
||||
# Check if this group must be notified
|
||||
if alert_type in receiver_group['contents'] and notification_id not in ignore_list:
|
||||
if alert_type in receiver_group['contents'] and notification_id not in ignore_list and key not in already_added_keys:
|
||||
receiver_groups[group_name]["notifications"].append(
|
||||
notification)
|
||||
already_added_keys.append(key)
|
||||
|
||||
return receiver_groups
|
||||
|
||||
|
||||
Reference in New Issue
Block a user