Merge pull request #8035 from Icinga/feature/expiry-date-comments-4663

/v1/actions/add-comment: add param expiry
This commit is contained in:
Julian Brost 2020-12-04 15:48:50 +01:00 committed by GitHub
commit f2a532de32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -274,9 +274,15 @@ Dictionary::Ptr ApiActions::AddComment(const ConfigObject::Ptr& object,
if (!params->Contains("author") || !params->Contains("comment"))
return ApiActions::CreateResult(400, "Comments require author and comment.");
double timestamp = 0.0;
if (params->Contains("expiry")) {
timestamp = HttpUtility::GetLastParameter(params, "expiry");
}
String commentName = Comment::AddComment(checkable, CommentUser,
HttpUtility::GetLastParameter(params, "author"),
HttpUtility::GetLastParameter(params, "comment"), false, 0);
HttpUtility::GetLastParameter(params, "comment"), false, timestamp);
Comment::Ptr comment = Comment::GetByName(commentName);