]> granicus.if.org Git - icinga2/commitdiff
Return 500 when no api action is successful
authorJean Flach <jean-marcel.flach@icinga.com>
Thu, 5 Apr 2018 08:47:17 +0000 (10:47 +0200)
committerJean Flach <jean-marcel.flach@icinga.com>
Thu, 5 Apr 2018 13:56:06 +0000 (15:56 +0200)
fixes #5095

lib/remote/actionshandler.cpp

index a8b31fc1099bf822ba96cc73106ce6e135610def..9358f7b32b682711036fb13679eba54d5ad522fa 100644 (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;