Skip to content

Commit

Permalink
Notification: Fix incorrectly dropped recovery & ACK notifications
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yhabteab committed Nov 11, 2024
1 parent 9a8620d commit ec09f9c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/icinga/notification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,14 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
continue;
}

// Verify if the 'Problem' filter is configured at both the User and Notification object levels.
bool foundProblemFilter = NotificationProblem & user->GetTypeFilter() & GetTypeFilter();

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

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

0 comments on commit ec09f9c

Please sign in to comment.