Introduce Comment#sticky

Carries whether ack was sticky for ack comments.
This commit is contained in:
Alexander A. Klimov 2022-03-21 15:41:22 +01:00
parent b4fd4c6131
commit 4399e82d9d
5 changed files with 9 additions and 7 deletions

View File

@ -243,7 +243,7 @@ Dictionary::Ptr ApiActions::AcknowledgeProblem(const ConfigObject::Ptr& object,
}
Comment::AddComment(checkable, CommentAcknowledgement, HttpUtility::GetLastParameter(params, "author"),
HttpUtility::GetLastParameter(params, "comment"), persistent, timestamp);
HttpUtility::GetLastParameter(params, "comment"), persistent, timestamp, sticky == AcknowledgementSticky);
checkable->AcknowledgeProblem(HttpUtility::GetLastParameter(params, "author"),
HttpUtility::GetLastParameter(params, "comment"), sticky, notify, persistent, Utility::GetTime(), timestamp);

View File

@ -131,7 +131,7 @@ int Comment::GetNextCommentID()
}
String Comment::AddComment(const Checkable::Ptr& checkable, CommentType entryType, const String& author,
const String& text, bool persistent, double expireTime, const String& id, const MessageOrigin::Ptr& origin)
const String& text, bool persistent, double expireTime, bool sticky, const String& id, const MessageOrigin::Ptr& origin)
{
String fullName;
@ -147,6 +147,7 @@ String Comment::AddComment(const Checkable::Ptr& checkable, CommentType entryTyp
attrs->Set("persistent", persistent);
attrs->Set("expire_time", expireTime);
attrs->Set("entry_type", entryType);
attrs->Set("sticky", sticky);
attrs->Set("entry_time", Utility::GetTime());
Host::Ptr host;

View File

@ -35,7 +35,7 @@ public:
static int GetNextCommentID();
static String AddComment(const intrusive_ptr<Checkable>& checkable, CommentType entryType,
const String& author, const String& text, bool persistent, double expireTime,
const String& author, const String& text, bool persistent, double expireTime, bool sticky = false,
const String& id = String(), const MessageOrigin::Ptr& origin = nullptr);
static void RemoveComment(const String& id, bool removedManually = false, const String& removedBy = "",

View File

@ -66,6 +66,7 @@ class Comment : ConfigObject < CommentNameComposer
[config, enum] CommentType entry_type {
default {{{ return CommentUser; }}}
};
[config, no_user_view, no_user_modify] bool sticky;
[config, required] String author;
[config, required] String text;
[config] bool persistent;

View File

@ -616,7 +616,7 @@ void ExternalCommandProcessor::AcknowledgeSvcProblem(double, const std::vector<S
Log(LogNotice, "ExternalCommandProcessor")
<< "Setting acknowledgement for service '" << service->GetName() << "'" << (notify ? "" : ". Disabled notification");
Comment::AddComment(service, CommentAcknowledgement, arguments[5], arguments[6], persistent, 0);
Comment::AddComment(service, CommentAcknowledgement, arguments[5], arguments[6], persistent, 0, sticky);
service->AcknowledgeProblem(arguments[5], arguments[6], sticky ? AcknowledgementSticky : AcknowledgementNormal, notify, persistent);
}
@ -646,7 +646,7 @@ void ExternalCommandProcessor::AcknowledgeSvcProblemExpire(double, const std::ve
Log(LogNotice, "ExternalCommandProcessor")
<< "Setting timed acknowledgement for service '" << service->GetName() << "'" << (notify ? "" : ". Disabled notification");
Comment::AddComment(service, CommentAcknowledgement, arguments[6], arguments[7], persistent, timestamp);
Comment::AddComment(service, CommentAcknowledgement, arguments[6], arguments[7], persistent, timestamp, sticky);
service->AcknowledgeProblem(arguments[6], arguments[7], sticky ? AcknowledgementSticky : AcknowledgementNormal, notify, persistent, timestamp);
}
@ -690,7 +690,7 @@ void ExternalCommandProcessor::AcknowledgeHostProblem(double, const std::vector<
BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[1] + "' is already acknowledged."));
}
Comment::AddComment(host, CommentAcknowledgement, arguments[4], arguments[5], persistent, 0);
Comment::AddComment(host, CommentAcknowledgement, arguments[4], arguments[5], persistent, 0, sticky);
host->AcknowledgeProblem(arguments[4], arguments[5], sticky ? AcknowledgementSticky : AcknowledgementNormal, notify, persistent);
}
@ -720,7 +720,7 @@ void ExternalCommandProcessor::AcknowledgeHostProblemExpire(double, const std::v
BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[1] + "' is already acknowledged."));
}
Comment::AddComment(host, CommentAcknowledgement, arguments[5], arguments[6], persistent, timestamp);
Comment::AddComment(host, CommentAcknowledgement, arguments[5], arguments[6], persistent, timestamp, sticky);
host->AcknowledgeProblem(arguments[5], arguments[6], sticky ? AcknowledgementSticky : AcknowledgementNormal, notify, persistent, timestamp);
}