feat: enhance error handling and permissions in Admin and Report services

This commit is contained in:
gabdevele
2026-06-14 21:37:12 +02:00 Unverified
parent 002f89bd73
commit ca09e7b6c8
5 changed files with 93 additions and 14 deletions
+13 -2
View File
@@ -56,8 +56,19 @@ void sendAdmin(Json::Value body,
}
const auto error = body.get("error", "").asString();
const auto status = error == "forbidden" ? drogon::k403Forbidden
: drogon::k400BadRequest;
drogon::HttpStatusCode status = drogon::k400BadRequest;
if (error == "forbidden" || error.rfind("cannot_", 0) == 0)
{
status = drogon::k403Forbidden;
}
else if (error.ends_with("_not_found"))
{
status = drogon::k404NotFound;
}
else if (error == "invalid_status_transition")
{
status = drogon::k409Conflict;
}
callback(visione::http::json(std::move(body), status));
}
} // namespace
+14 -2
View File
@@ -58,8 +58,20 @@ void sendService(Json::Value body,
return;
}
const auto error = body.get("error", "").asString();
const auto status = error == "forbidden" ? drogon::k403Forbidden
: drogon::k400BadRequest;
drogon::HttpStatusCode status = drogon::k400BadRequest;
if (error == "forbidden" || error.rfind("cannot_", 0) == 0)
{
status = drogon::k403Forbidden;
}
else if (error.ends_with("_not_found"))
{
status = drogon::k404NotFound;
}
else if (error == "invalid_status_transition" ||
error == "media_limit_reached")
{
status = drogon::k409Conflict;
}
callback(visione::http::json(std::move(body), status));
}