mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-19 11:12:49 +00:00
feat(dashboard): reprocess or remove every model on a property
The property page gets a Reprocess all models button (ugc_manage): every
model placed on the property goes back to the UGC server's queue, made
again with the current settings (/api/ugc/reprocess with {property}).
Import models gets Remove all models (properties_import): deletes every
model placed on the property after the property id is typed in, refused
while the property is loaded in a world, as import is.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -281,4 +281,23 @@ void RegisterMaintenanceRoutes() {
|
||||
BroadcastTableChanged("properties", std::to_string(*propertyId));
|
||||
JsonSuccess(reply, { {"models", created}, {"message", "Imported " + std::to_string(created.size()) + " model(s)"} });
|
||||
});
|
||||
|
||||
Route(eHTTPMethod::POST, "/api/properties/:id/remove_models", Perm("properties_import"),
|
||||
"Delete every model placed on a property (they don't go back to the owner). Body: {confirm: the property ID}",
|
||||
[](HTTPReply& reply, const HTTPContext& context) {
|
||||
const auto propertyId = PathId<LWOOBJID>(context.path, 2);
|
||||
const auto body = ParseBody(context);
|
||||
if (!propertyId) return JsonError(reply, eHTTPStatusCode::BAD_REQUEST, "Invalid ID");
|
||||
if (!body || body->value("confirm", std::string()) != std::to_string(*propertyId)) return JsonError(reply, eHTTPStatusCode::BAD_REQUEST, "Confirm with the property ID");
|
||||
const auto property = Database::Get()->GetPropertyInfo(*propertyId);
|
||||
if (!property) return JsonError(reply, eHTTPStatusCode::NOT_FOUND, "Property not found");
|
||||
// A loaded property keeps its own list of models and saves it back
|
||||
if (PropertyInstanceRunning(property->cloneId)) return JsonError(reply, eHTTPStatusCode::CONFLICT, "This property is loaded in a world right now; try again when nobody is on it");
|
||||
|
||||
const auto models = Database::Get()->GetPropertyModels(*propertyId);
|
||||
for (const auto& model : models) Database::Get()->RemoveModel(model.id);
|
||||
Audit(context, "remove_property_models", std::to_string(models.size()) + " model(s) from property " + std::to_string(*propertyId));
|
||||
BroadcastTableChanged("properties", std::to_string(*propertyId));
|
||||
JsonSuccess(reply, { {"removed", models.size()}, {"message", "Removed " + std::to_string(models.size()) + " model(s)"} });
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user