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:
vitor-aignosi
2025-07-29 12:13:08 -03:00
parent 6f6094b2ce
commit 263410b292
2 changed files with 10 additions and 2 deletions

View File

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

View File

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