]> granicus.if.org Git - icinga2/commitdiff
Fix that recovery notifications are sent if notified for !Problem type before
authorMichael Friedrich <michael.friedrich@icinga.com>
Tue, 15 Nov 2016 14:12:26 +0000 (15:12 +0100)
committerMichael Friedrich <michael.friedrich@icinga.com>
Thu, 17 Nov 2016 09:35:16 +0000 (10:35 +0100)
fixes #13205

lib/icinga/clusterevents.cpp
lib/icinga/notification.cpp
lib/icinga/notification.ti

index 1f09523562c974e7f032435fd2a8231c8dd3f8ce..deaceb60c6a6458590d6d43216c33acdd68232ca 100644 (file)
@@ -1097,12 +1097,12 @@ Value ClusterEvents::NotificationSentToAllUsersAPIHandler(const MessageOrigin::P
        notification->SetLastProblemNotification(params->Get("last_problem_notification"));
        notification->SetNoMoreNotifications(params->Get("no_more_notifications"));
 
-       Array::Ptr notifiedUsers = new Array();
+       Array::Ptr notifiedProblemUsers = new Array();
        for (const User::Ptr& user : users) {
-               notifiedUsers->Add(user->GetName());
+               notifiedProblemUsers->Add(user->GetName());
        }
 
-       notification->SetNotifiedUsers(notifiedUsers);
+       notification->SetNotifiedProblemUsers(notifiedProblemUsers);
 
        Checkable::OnNotificationSentToAllUsers(notification, checkable, users, type, cr, author, text, origin);
 
index 305be8fefa4f1dae969fe89675b5b4a8808bd1e2..7701de4d1702252a3ae00d4aba6527fdaf9f08b7 100644 (file)
@@ -386,7 +386,7 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
        }
 
        std::set<User::Ptr> allNotifiedUsers;
-       Array::Ptr notifiedUsers = GetNotifiedUsers();
+       Array::Ptr notifiedProblemUsers = GetNotifiedProblemUsers();
 
        for (const User::Ptr& user : allUsers) {
                String userName = user->GetName();
@@ -405,9 +405,9 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
 
                /* on recovery, check if user was notified before */
                if (type == NotificationRecovery) {
-                       if (!notifiedUsers->Contains(userName)) {
+                       if (!notifiedProblemUsers->Contains(userName)) {
                                Log(LogNotice, "Notification")
-                                   << "We did not notify user '" << userName << "' before. Not sending recovery notification.";
+                                   << "We did not notify user '" << userName << "' for a problem before. Not sending recovery notification.";
                                continue;
                        }
                }
@@ -422,13 +422,13 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
                allNotifiedUsers.insert(user);
 
                /* store all notified users for later recovery checks */
-               if (!notifiedUsers->Contains(userName))
-                       notifiedUsers->Add(userName);
+               if (type == NotificationProblem && !notifiedProblemUsers->Contains(userName))
+                       notifiedProblemUsers->Add(userName);
        }
 
        /* if this was a recovery notification, reset all notified users */
        if (type == NotificationRecovery)
-               notifiedUsers->Clear();
+               notifiedProblemUsers->Clear();
 
        /* used in db_ido for notification history */
        Service::OnNotificationSentToAllUsers(this, checkable, allNotifiedUsers, type, cr, author, text, MessageOrigin::Ptr());
index 2445c2d942ba6411a768be9c55fa32d70d654017..12922d6bf0d1052c282a5f26ffbd5c9f31a338eb 100644 (file)
@@ -86,7 +86,7 @@ class Notification : CustomVarObject < NotificationNameComposer
                }}}
        };
 
-       [state, no_user_modify] Array::Ptr notified_users {
+       [state, no_user_modify] Array::Ptr notified_problem_users {
                default {{{ return new Array(); }}}
        };