improve splits
All checks were successful
Server Build / publish (push) Successful in 30s
Voice Build / publish (push) Successful in 25s

This commit is contained in:
olcxja 2026-05-29 08:54:36 +02:00
commit 442add0ee4

View file

@ -59,8 +59,9 @@ public class Utils
public static string GetIdFromUsernameWD(string usernameWD)
{
int colonIndex = usernameWD.IndexOf(':');
return colonIndex == -1 ? usernameWD : usernameWD.Substring(0, colonIndex);
int separatorIndex = usernameWD.IndexOf(':');
if (separatorIndex == -1) separatorIndex = usernameWD.IndexOf(';');
return separatorIndex == -1 ? usernameWD : usernameWD.Substring(0, separatorIndex);
}
public static string GetValidIdOrZero(string input)
@ -78,13 +79,15 @@ public class Utils
public static bool IsUserLocal(string usernameWD, out string domain)
{
int colonIndex = usernameWD.IndexOf(':');
if (colonIndex == -1 || usernameWD.EndsWith(":" + DOMAIN))
int separatorIndex = usernameWD.IndexOf(':');
if (separatorIndex == -1) separatorIndex = usernameWD.IndexOf(';');
if (separatorIndex == -1 || usernameWD.EndsWith(":" + DOMAIN) || usernameWD.EndsWith(";" + DOMAIN))
{
domain = DOMAIN;
return true;
}
domain = usernameWD.Substring(colonIndex + 1);
domain = usernameWD.Substring(separatorIndex + 1);
return false;
}
@ -346,19 +349,20 @@ public class Utils
string path = $"{ACCOUNTS_DATA_DIR}/{id}/dms";
if (!Fs.Exists(path))
{
return "{}";
return "{\"dms\":{}}";
}
StringBuilder dmsBuilder = new StringBuilder("{");
StringBuilder dmsBuilder = new StringBuilder("\"dms\":{");
string[] dmFiles = Fs.ReadDirectory(path);
for (int i = 0; i < dmFiles.Length; i++)
{
if (i > 0) dmsBuilder.Append(',');
dmsBuilder.Append($"\"{dmFiles[i]}\":");
dmsBuilder.Append(Encoding.UTF8.GetString(await Fs.ReadFile($"{path}/{dmFiles[i]}")));
}
dmsBuilder.Append("}");
return dmsBuilder.ToString();
return $"{{{dmsBuilder.ToString()}}}";
}
public static async Task RemoveOldestDmIndex(string id) //i wont implement this, client should just warn users that they have like 99999999 dms and should leave some