From 22c3a7933e19bf4063ea1f7e4c1d9281f6393475 Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Fri, 6 Apr 2018 10:03:09 +0200 Subject: [PATCH] Fix API action status codes --- lib/remote/actionshandler.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/remote/actionshandler.cpp b/lib/remote/actionshandler.cpp index 9358f7b32..614ca6f87 100644 --- a/lib/remote/actionshandler.cpp +++ b/lib/remote/actionshandler.cpp @@ -91,15 +91,19 @@ bool ActionsHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& reques } } - response.SetStatus(500, "No action executed successfully"); + String statusCode = 500; + String statusMessage = "No action executed successfully"; for (const Dictionary::Ptr& res : results) { - if (res->Contains("result") && res->Get("result") == 200) { - response.SetStatus(200, "OK"); + if (res->Contains("code") && res->Get("code") == 200) { + statusCode = 200; + statusMessage = "OK"; break; } } + response.SetStatus(statusCode, statusMessage); + Dictionary::Ptr result = new Dictionary({ { "results", new Array(std::move(results)) } });