From dceb29c742d5189a8f06e8957f740f37fca736e5 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 3 Mar 2023 11:53:02 +0100 Subject: [PATCH] Checkable#RemoveCommentsByType(): remove redundant parameter --- lib/icinga/apiactions.cpp | 2 +- lib/icinga/checkable-check.cpp | 2 +- lib/icinga/checkable-comment.cpp | 11 ++++++----- lib/icinga/checkable.hpp | 2 +- lib/icinga/externalcommandprocessor.cpp | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/icinga/apiactions.cpp b/lib/icinga/apiactions.cpp index 1e3fe851f..83b6a60a8 100644 --- a/lib/icinga/apiactions.cpp +++ b/lib/icinga/apiactions.cpp @@ -275,7 +275,7 @@ Dictionary::Ptr ApiActions::RemoveAcknowledgement(const ConfigObject::Ptr& objec String removedBy (HttpUtility::GetLastParameter(params, "author")); checkable->ClearAcknowledgement(removedBy); - checkable->RemoveCommentsByType(CommentAcknowledgement, removedBy); + checkable->RemoveAckComments(removedBy); return ApiActions::CreateResult(200, "Successfully removed acknowledgement for object '" + checkable->GetName() + "'."); } diff --git a/lib/icinga/checkable-check.cpp b/lib/icinga/checkable-check.cpp index 83c39e923..ea2428588 100644 --- a/lib/icinga/checkable-check.cpp +++ b/lib/icinga/checkable-check.cpp @@ -321,7 +321,7 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr olock.Unlock(); if (remove_acknowledgement_comments) - RemoveCommentsByType(CommentAcknowledgement); + RemoveAckComments(); Dictionary::Ptr vars_after = new Dictionary({ { "state", new_state }, diff --git a/lib/icinga/checkable-comment.cpp b/lib/icinga/checkable-comment.cpp index 135f35520..29fc65563 100644 --- a/lib/icinga/checkable-comment.cpp +++ b/lib/icinga/checkable-comment.cpp @@ -19,14 +19,15 @@ void Checkable::RemoveAllComments() } } -void Checkable::RemoveCommentsByType(int type, const String& removedBy) +void Checkable::RemoveAckComments(const String& removedBy) { for (const Comment::Ptr& comment : GetComments()) { - /* Do not remove persistent comments from an acknowledgement */ - if (comment->GetEntryType() == CommentAcknowledgement && comment->GetPersistent()) - continue; + if (comment->GetEntryType() == CommentAcknowledgement) { + /* Do not remove persistent comments from an acknowledgement */ + if (comment->GetPersistent()) { + continue; + } - if (comment->GetEntryType() == type) { { ObjectLock oLock (comment); comment->SetRemovedBy(removedBy); diff --git a/lib/icinga/checkable.hpp b/lib/icinga/checkable.hpp index 6a46425a9..96df5bd47 100644 --- a/lib/icinga/checkable.hpp +++ b/lib/icinga/checkable.hpp @@ -156,7 +156,7 @@ public: /* Comments */ void RemoveAllComments(); - void RemoveCommentsByType(int type, const String& removedBy = String()); + void RemoveAckComments(const String& removedBy = String()); std::set GetComments() const; Comment::Ptr GetLastComment() const; diff --git a/lib/icinga/externalcommandprocessor.cpp b/lib/icinga/externalcommandprocessor.cpp index f781a3412..9850da030 100644 --- a/lib/icinga/externalcommandprocessor.cpp +++ b/lib/icinga/externalcommandprocessor.cpp @@ -665,7 +665,7 @@ void ExternalCommandProcessor::RemoveSvcAcknowledgement(double, const std::vecto service->ClearAcknowledgement(""); } - service->RemoveCommentsByType(CommentAcknowledgement); + service->RemoveAckComments(); } void ExternalCommandProcessor::AcknowledgeHostProblem(double, const std::vector& arguments) @@ -738,7 +738,7 @@ void ExternalCommandProcessor::RemoveHostAcknowledgement(double, const std::vect ObjectLock olock(host); host->ClearAcknowledgement(""); } - host->RemoveCommentsByType(CommentAcknowledgement); + host->RemoveAckComments(); } void ExternalCommandProcessor::EnableHostgroupSvcChecks(double, const std::vector& arguments)