Fix that recovery notifications are sent if notified for !Problem type before

fixes #13205
This commit is contained in:
Michael Friedrich 2016-11-15 15:12:26 +01:00
parent f58d3a1838
commit 35ce166bd2
3 changed files with 10 additions and 10 deletions

View 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);

View 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());

View 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(); }}}
};