mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-24 06:05:01 +02:00
AddComment: return Comment::Ptr instead of String containing the name
Mimic 88e5744d54f79ab6a84260bd4a8d2cc0ffd43465 and address nullptr on concurrent add-comment / remove-comment actions.
This commit is contained in:
parent
ab58ff2928
commit
e6fc1b91a7
@ -316,11 +316,11 @@ Dictionary::Ptr ApiActions::AddComment(const ConfigObject::Ptr& object,
|
||||
return ApiActions::CreateResult(503, "Icinga is reloading.");
|
||||
}
|
||||
|
||||
String commentName = Comment::AddComment(checkable, CommentUser,
|
||||
Comment::Ptr comment = Comment::AddComment(checkable, CommentUser,
|
||||
HttpUtility::GetLastParameter(params, "author"),
|
||||
HttpUtility::GetLastParameter(params, "comment"), false, timestamp);
|
||||
|
||||
Comment::Ptr comment = Comment::GetByName(commentName);
|
||||
String commentName = comment->GetName();
|
||||
|
||||
Dictionary::Ptr additional = new Dictionary({
|
||||
{ "name", commentName },
|
||||
|
@ -130,7 +130,7 @@ int Comment::GetNextCommentID()
|
||||
return l_NextCommentID;
|
||||
}
|
||||
|
||||
String Comment::AddComment(const Checkable::Ptr& checkable, CommentType entryType, const String& author,
|
||||
Comment::Ptr Comment::AddComment(const Checkable::Ptr& checkable, CommentType entryType, const String& author,
|
||||
const String& text, bool persistent, double expireTime, bool sticky, const String& id, const MessageOrigin::Ptr& origin)
|
||||
{
|
||||
String fullName;
|
||||
@ -184,7 +184,7 @@ String Comment::AddComment(const Checkable::Ptr& checkable, CommentType entryTyp
|
||||
Log(LogNotice, "Comment")
|
||||
<< "Added comment '" << comment->GetName() << "'.";
|
||||
|
||||
return fullName;
|
||||
return comment;
|
||||
}
|
||||
|
||||
void Comment::RemoveComment(const String& id, bool removedManually, const String& removedBy,
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
|
||||
static int GetNextCommentID();
|
||||
|
||||
static String AddComment(const intrusive_ptr<Checkable>& checkable, CommentType entryType,
|
||||
static Ptr AddComment(const intrusive_ptr<Checkable>& checkable, CommentType entryType,
|
||||
const String& author, const String& text, bool persistent, double expireTime, bool sticky = false,
|
||||
const String& id = String(), const MessageOrigin::Ptr& origin = nullptr);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user