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 0470fe12a7
commit c160c4b62e
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()) { for (const Comment::Ptr& comment : GetComments()) {
if (comment->GetEntryType() == CommentAcknowledgement) { if (comment->GetEntryType() == CommentAcknowledgement) {
@ -28,6 +28,10 @@ void Checkable::RemoveAckComments(const String& removedBy)
continue; continue;
} }
if (comment->GetEntryTime() > createdBefore) {
continue;
}
{ {
ObjectLock oLock (comment); ObjectLock oLock (comment);
comment->SetRemovedBy(removedBy); comment->SetRemovedBy(removedBy);

View File

@ -17,6 +17,7 @@
#include <condition_variable> #include <condition_variable>
#include <cstdint> #include <cstdint>
#include <functional> #include <functional>
#include <limits>
namespace icinga namespace icinga
{ {
@ -149,7 +150,7 @@ public:
/* Comments */ /* Comments */
void RemoveAllComments(); 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; std::set<Comment::Ptr> GetComments() const;
Comment::Ptr GetLastComment() const; Comment::Ptr GetLastComment() const;