mirror of https://github.com/Icinga/icinga2.git
/v1/actions/remove-acknowledgement: let users specify themselves
This commit is contained in:
parent
d84efecb62
commit
80bf316e7b
|
@ -245,7 +245,7 @@ Dictionary::Ptr ApiActions::RemoveAcknowledgement(const ConfigObject::Ptr& objec
|
|||
+ object->GetName() + ".");
|
||||
|
||||
checkable->ClearAcknowledgement();
|
||||
checkable->RemoveCommentsByType(CommentAcknowledgement);
|
||||
checkable->RemoveCommentsByType(CommentAcknowledgement, HttpUtility::GetLastParameter(params, "author"));
|
||||
|
||||
return ApiActions::CreateResult(200, "Successfully removed acknowledgement for object '" + checkable->GetName() + "'.");
|
||||
}
|
||||
|
|
|
@ -18,16 +18,22 @@ void Checkable::RemoveAllComments()
|
|||
}
|
||||
}
|
||||
|
||||
void Checkable::RemoveCommentsByType(int type)
|
||||
void Checkable::RemoveCommentsByType(int type, 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() == type)
|
||||
if (comment->GetEntryType() == type) {
|
||||
{
|
||||
ObjectLock oLock (comment);
|
||||
comment->SetRemovedBy(removedBy);
|
||||
}
|
||||
|
||||
Comment::RemoveComment(comment->GetName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::set<Comment::Ptr> Checkable::GetComments() const
|
||||
|
|
|
@ -133,7 +133,7 @@ public:
|
|||
|
||||
/* Comments */
|
||||
void RemoveAllComments();
|
||||
void RemoveCommentsByType(int type);
|
||||
void RemoveCommentsByType(int type, const String& removedBy = String());
|
||||
|
||||
std::set<Comment::Ptr> GetComments() const;
|
||||
void RegisterComment(const Comment::Ptr& comment);
|
||||
|
|
Loading…
Reference in New Issue