Skip to content

Commit 557a8af

Browse files
committed
Notification: Fix incorrectly dropped recovery & ACK notifications
Previously, recovery and ACK notifications were not delivered to users who weren't notified about the problem state while having a configured `Problem` type filter. However, since the type filter can also be configured on the `Notification` object level, this resulted to an incorrect behaviour. This PR changes the existing logic so that the recovery and ACK notifications gets dropped only if the `Problem` filter is configured on both the `User` and `Notification` object levels.
1 parent 9a8620d commit 557a8af

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/icinga/notification.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,14 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
428428
continue;
429429
}
430430

431+
// Verify if the 'Problem' filter is configured at both the User and Notification object levels.
432+
bool foundProblemFilter = NotificationProblem & user->GetTypeFilter() && NotificationProblem & GetTypeFilter();
433+
431434
/* on recovery, check if user was notified before */
432435
if (type == NotificationRecovery) {
433-
if (!notifiedProblemUsers->Contains(userName) && (NotificationProblem & user->GetTypeFilter())) {
436+
// Do not send a recovery notification to the current user if he was not previously notified of the
437+
// problem state, while containing the 'Problem' filter at both the user and notification object levels.
438+
if (!notifiedProblemUsers->Contains(userName) && foundProblemFilter) {
434439
Log(LogNotice, "Notification")
435440
<< "Notification object '" << notificationName << "': We did not notify user '" << userName
436441
<< "' (Problem types enabled) for a problem before. Not sending Recovery notification.";
@@ -440,7 +445,9 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
440445

441446
/* on acknowledgement, check if user was notified before */
442447
if (type == NotificationAcknowledgement) {
443-
if (!notifiedProblemUsers->Contains(userName) && (NotificationProblem & user->GetTypeFilter())) {
448+
// Do not send an ACK notification to the current user if he wasn't previously notified of the problem
449+
// state, while containing the 'Problem' filter at both the user and notification object levels.
450+
if (!notifiedProblemUsers->Contains(userName) && foundProblemFilter) {
444451
Log(LogNotice, "Notification")
445452
<< "Notification object '" << notificationName << "': We did not notify user '" << userName
446453
<< "' (Problem types enabled) for a problem before. Not sending acknowledgement notification.";

0 commit comments

Comments
 (0)