/v1/actions/remove-acknowledgement: let users specify themselves

This commit is contained in:
Alexander A. Klimov 2019-11-21 16:28:22 +01:00
parent d84efecb62
commit 80bf316e7b
3 changed files with 10 additions and 4 deletions

View File

@ -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() + "'.");
} }

View File

@ -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());
}
} }
} }

View File

@ -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);