fixes lol
All checks were successful
Build and Push / build-all (push) Successful in 8m35s

This commit is contained in:
doomtube 2026-01-09 21:38:32 -05:00
parent 2e376269c2
commit c65967acd6
2 changed files with 43 additions and 14 deletions

View file

@ -630,31 +630,35 @@ void RealmController::updateRealm(const HttpRequestPtr &req,
}
>> DB_ERROR_MSG(callback, "update retention", "Failed to update retention");
} else if (json->isMember("name")) {
// Update realm name
std::string newName = (*json)["name"].asString();
// Update realm name (display name with optional uppercase)
std::string displayName = (*json)["name"].asString();
// Validate name format
if (!validateRealmName(newName)) {
callback(jsonError("Invalid realm name. Use 3-30 lowercase letters, numbers, and hyphens only."));
// Validate display name format
if (!validateRealmDisplayName(displayName)) {
callback(jsonError("Invalid realm name. Use 3-30 letters, numbers, and hyphens only."));
return;
}
// Check if name is already taken by another realm
// Generate lowercase slug for URL
std::string newSlug = toSlug(displayName);
// Check if slug is already taken by another realm
*dbClient << "SELECT id FROM realms WHERE name = $1 AND id != $2"
<< newName << id
>> [callback, dbClient, id, user, newName](const Result& nameCheck) {
<< newSlug << id
>> [callback, dbClient, id, user, displayName, newSlug](const Result& nameCheck) {
if (!nameCheck.empty()) {
callback(jsonError("Realm name is already taken"));
return;
}
*dbClient << "UPDATE realms SET name = $1 WHERE id = $2 AND user_id = $3"
<< newName << id << user.id
>> [callback, newName](const Result&) {
*dbClient << "UPDATE realms SET name = $1, display_name = $2 WHERE id = $3 AND user_id = $4"
<< newSlug << displayName << id << user.id
>> [callback, displayName, newSlug](const Result&) {
Json::Value resp;
resp["success"] = true;
resp["message"] = "Realm renamed successfully";
resp["name"] = newName;
resp["name"] = newSlug;
resp["displayName"] = displayName;
callback(jsonResp(resp));
}
>> DB_ERROR_MSG(callback, "rename realm", "Failed to rename realm");