Checkable#RemoveAckComments(): add optional comment entry time filter

This commit is contained in:
Alexander A. Klimov 2023-03-03 15:48:11 +01:00
parent dceb29c742
commit 4662d4477b
2 changed files with 7 additions and 2 deletions

View File

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

View File

@ -17,6 +17,7 @@
#include <condition_variable>
#include <cstdint>
#include <functional>
#include <limits>
namespace icinga
{
@ -156,7 +157,7 @@ public:
/* Comments */
void RemoveAllComments();
void RemoveAckComments(const String& removedBy = String());
void RemoveAckComments(const String& removedBy = String(), double createdBefore = std::numeric_limits<double>::max());
std::set<Comment::Ptr> GetComments() const;
Comment::Ptr GetLastComment() const;