-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for multiple notifications #4
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -416,7 +416,18 @@ def add(self, alert): | |
alertobj.trigger = alertobj.triggers.add(alert.trigger) | ||
if alert.notification: | ||
alertobj.notification = alertobj.notifications.add(alert.notification) | ||
if alert.trigger and alert.notification: | ||
elif alert.notifications and isinstance(alert.notifications, list): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
notifications = [] | ||
for notification in alert.notifications: | ||
notifications.append(alertobj.notifications.add(notification)) | ||
alertobj.notifications = notifications | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By this time, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I think this is not required now, since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if alert.trigger and alert.notifications: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't the logic here same as the existing logic for a single notification? You should be able to condense both into one loop (i.e., if you initialize a list with a single notification). |
||
alertobj.trigger.notificationsIds = [] | ||
for notification in alertobj.notifications: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would change to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I mentioned earlier, |
||
self.argus.alerts.add_notification_trigger(alertobj.id, notification.id, alertobj.trigger.id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this automatically connects notifications, but only when there is a single trigger. Could you add some additional documentation to this method on this behavior? |
||
notification.triggersIds = [alertobj.trigger.id] | ||
alertobj.trigger.notificationsIds.append(notification.id) | ||
elif alert.trigger and alert.notification: | ||
self.argus.alerts.add_notification_trigger(alertobj.id, alertobj.notification.id, alertobj.trigger.id) | ||
alertobj.notification.triggersIds = [alertobj.trigger.id] | ||
alertobj.trigger.notificationsIds = [alertobj.notification.id] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make the same change for
alert.triggers
also?