Return 500 when no api action is successful

fixes #5095
This commit is contained in:
Jean Flach 2018-04-05 10:47:17 +02:00
parent e08231f4df
commit 9b291be989
1 changed files with 9 additions and 1 deletions

View File

@ -91,11 +91,19 @@ bool ActionsHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& reques
}
}
response.SetStatus(500, "No action executed successfully");
for (const Dictionary::Ptr& res : results) {
if (res->Contains("result") && res->Get("result") == 200) {
response.SetStatus(200, "OK");
break;
}
}
Dictionary::Ptr result = new Dictionary({
{ "results", new Array(std::move(results)) }
});
response.SetStatus(200, "OK");
HttpUtility::SendJsonBody(response, params, result);
return true;