From c160c4b62e83a0c915698ce6f2f543b004d6769c Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 3 Mar 2023 15:48:11 +0100 Subject: [PATCH] Checkable#RemoveAckComments(): add optional comment entry time filter --- lib/icinga/checkable-comment.cpp | 6 +++++- lib/icinga/checkable.hpp | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/icinga/checkable-comment.cpp b/lib/icinga/checkable-comment.cpp index bc679e43d..eab3bcaa8 100644 --- a/lib/icinga/checkable-comment.cpp +++ b/lib/icinga/checkable-comment.cpp @@ -19,7 +19,7 @@ void Checkable::RemoveAllComments() } } -void Checkable::RemoveAckComments(const String& removedBy) +void Checkable::RemoveAckComments(const String& removedBy, double createdBefore) { for (const Comment::Ptr& comment : GetComments()) { if (comment->GetEntryType() == CommentAcknowledgement) { @@ -28,6 +28,10 @@ void Checkable::RemoveAckComments(const String& removedBy) continue; } + if (comment->GetEntryTime() > createdBefore) { + continue; + } + { ObjectLock oLock (comment); comment->SetRemovedBy(removedBy); diff --git a/lib/icinga/checkable.hpp b/lib/icinga/checkable.hpp index 54932e7be..b0a96dc8f 100644 --- a/lib/icinga/checkable.hpp +++ b/lib/icinga/checkable.hpp @@ -17,6 +17,7 @@ #include #include #include +#include namespace icinga { @@ -149,7 +150,7 @@ public: /* Comments */ void RemoveAllComments(); - void RemoveAckComments(const String& removedBy = String()); + void RemoveAckComments(const String& removedBy = String(), double createdBefore = std::numeric_limits::max()); std::set GetComments() const; Comment::Ptr GetLastComment() const;