diff --git a/lib/icinga/apiactions.cpp b/lib/icinga/apiactions.cpp index 885834edc..781705b64 100644 --- a/lib/icinga/apiactions.cpp +++ b/lib/icinga/apiactions.cpp @@ -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 }, diff --git a/lib/icinga/comment.cpp b/lib/icinga/comment.cpp index 9c0b92359..0d1967440 100644 --- a/lib/icinga/comment.cpp +++ b/lib/icinga/comment.cpp @@ -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, diff --git a/lib/icinga/comment.hpp b/lib/icinga/comment.hpp index 653208478..a230040f8 100644 --- a/lib/icinga/comment.hpp +++ b/lib/icinga/comment.hpp @@ -34,7 +34,7 @@ public: static int GetNextCommentID(); - static String AddComment(const intrusive_ptr& checkable, CommentType entryType, + static Ptr AddComment(const intrusive_ptr& 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);