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 537fbd0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/icinga/notification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,16 @@ 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 notify the user about the recovery of a problem that they have not been notified about,
// unless they are explicitly configured to receive recovery notifications but no problem ones, or
// this Notification instance isn't allowed to send problem notifications (doesn't contain the
// 'Problem' type filter).
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 +447,10 @@ 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 notify the user about the ACK of a problem state that they have not been notified about, unless
// they are explicitly configured to receive ACK notifications but no problem ones, or this Notification
// instance isn't allowed to send problem notifications (doesn't contain the 'Problem' type filter).
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 537fbd0

Please sign in to comment.