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() + ".");
|
+ object->GetName() + ".");
|
||||||
|
|
||||||
checkable->ClearAcknowledgement();
|
checkable->ClearAcknowledgement();
|
||||||
checkable->RemoveCommentsByType(CommentAcknowledgement);
|
checkable->RemoveCommentsByType(CommentAcknowledgement, HttpUtility::GetLastParameter(params, "author"));
|
||||||
|
|
||||||
return ApiActions::CreateResult(200, "Successfully removed acknowledgement for object '" + checkable->GetName() + "'.");
|
return ApiActions::CreateResult(200, "Successfully removed acknowledgement for object '" + checkable->GetName() + "'.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,21 @@ void Checkable::RemoveAllComments()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Checkable::RemoveCommentsByType(int type)
|
void Checkable::RemoveCommentsByType(int type, const String& removedBy)
|
||||||
{
|
{
|
||||||
for (const Comment::Ptr& comment : GetComments()) {
|
for (const Comment::Ptr& comment : GetComments()) {
|
||||||
/* Do not remove persistent comments from an acknowledgement */
|
/* Do not remove persistent comments from an acknowledgement */
|
||||||
if (comment->GetEntryType() == CommentAcknowledgement && comment->GetPersistent())
|
if (comment->GetEntryType() == CommentAcknowledgement && comment->GetPersistent())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (comment->GetEntryType() == type)
|
if (comment->GetEntryType() == type) {
|
||||||
|
{
|
||||||
|
ObjectLock oLock (comment);
|
||||||
|
comment->SetRemovedBy(removedBy);
|
||||||
|
}
|
||||||
|
|
||||||
Comment::RemoveComment(comment->GetName());
|
Comment::RemoveComment(comment->GetName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ public:
|
||||||
|
|
||||||
/* Comments */
|
/* Comments */
|
||||||
void RemoveAllComments();
|
void RemoveAllComments();
|
||||||
void RemoveCommentsByType(int type);
|
void RemoveCommentsByType(int type, const String& removedBy = String());
|
||||||
|
|
||||||
std::set<Comment::Ptr> GetComments() const;
|
std::set<Comment::Ptr> GetComments() const;
|
||||||
void RegisterComment(const Comment::Ptr& comment);
|
void RegisterComment(const Comment::Ptr& comment);
|
||||||
|
|
Loading…
Reference in New Issue