From 10e5243cc4c9d31117b7546b8260903bafc5cd40 Mon Sep 17 00:00:00 2001 From: Tiago Garcia Date: Fri, 19 Jul 2024 11:58:53 +0100 Subject: [PATCH] Add actions to response Signed-off-by: Tiago Garcia --- src/endpoints/update-files.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/endpoints/update-files.cpp b/src/endpoints/update-files.cpp index 6af1654..858c661 100644 --- a/src/endpoints/update-files.cpp +++ b/src/endpoints/update-files.cpp @@ -121,7 +121,11 @@ crow::response update_files(const nlohmann::json& config_update_files, const nlo {"status", 200}, {"message", "OK"}, {"file_count", 0}, - {"updated-files", nlohmann::json::array()} + {"updated-files", nlohmann::json::array()}, + {"post-update", { + {"successful", nlohmann::json::array()}, + {"failed", nlohmann::json::array()} + }} }; for (auto &file : modified_files) { std::string remote_path = file[0]; @@ -151,8 +155,10 @@ crow::response update_files(const nlohmann::json& config_update_files, const nlo int return_code = std::system(action.c_str()); if (return_code == 0) { Logger::success("[/update-files] Post-update action " + action + " ran successfully"); + response["post-update"]["successful"].push_back(action); } else { Logger::error("[/update-files] Post-update action " + action + " failed with return code " + std::to_string(return_code)); + response["post-update"]["failed"].push_back(action); } }