mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 17:32:42 +08:00
reduce number of useless strings on get displaynames cap
This commit is contained in:
@@ -656,6 +656,122 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<UserData> GetKnownUsers(string[] ids, UUID scopeID)
|
||||
{
|
||||
if (m_Scenes.Count <= 0)
|
||||
return new List<UserData>();
|
||||
|
||||
var ret = new List<UserData>(ids.Length);
|
||||
|
||||
List<string> missing = new List<string>(ids.Length);
|
||||
var untried = new Dictionary<UUID, UserData>();
|
||||
foreach (string id in ids)
|
||||
{
|
||||
if (!UUID.TryParse(id, out UUID uuid) || uuid.IsZero())
|
||||
continue;
|
||||
|
||||
if (m_userCacheByID.TryGetValue(uuid, out UserData userdata))
|
||||
{
|
||||
if (userdata.HasGridUserTried)
|
||||
{
|
||||
if (!userdata.IsUnknownUser)
|
||||
ret.Add(userdata);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
untried[uuid] = userdata;
|
||||
}
|
||||
missing.Add(id);
|
||||
}
|
||||
|
||||
if (missing.Count == 0)
|
||||
return ret;
|
||||
|
||||
ids = null;
|
||||
|
||||
List<UserAccount> accounts = m_userAccountService.GetUserAccounts(scopeID, missing);
|
||||
if (accounts.Count != 0)
|
||||
{
|
||||
foreach (UserAccount uac in accounts)
|
||||
{
|
||||
if (uac != null)
|
||||
{
|
||||
UUID id = uac.PrincipalID;
|
||||
|
||||
var userdata = new UserData();
|
||||
userdata.Id = id;
|
||||
userdata.FirstName = uac.FirstName;
|
||||
userdata.LastName = uac.LastName;
|
||||
userdata.HomeURL = string.Empty;
|
||||
userdata.IsUnknownUser = false;
|
||||
userdata.IsLocal = true;
|
||||
userdata.HasGridUserTried = true;
|
||||
m_userCacheByID.Add(id, userdata, 1800000);
|
||||
|
||||
ret.Add(userdata);
|
||||
missing.Remove(id.ToString()); // slowww
|
||||
untried.Remove(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (missing.Count == 0 || m_gridUserService == null)
|
||||
return ret;
|
||||
|
||||
GridUserInfo[] pinfos = m_gridUserService.GetGridUserInfo(missing.ToArray());
|
||||
missing = null;
|
||||
if (pinfos.Length > 0)
|
||||
{
|
||||
foreach (GridUserInfo uInfo in pinfos)
|
||||
{
|
||||
if (uInfo != null && uInfo.UserID.Length >= 36)
|
||||
{
|
||||
if (Util.ParseFullUniversalUserIdentifier(uInfo.UserID, out UUID uuid, out string url, out string first, out string last))
|
||||
{
|
||||
bool isvalid = CheckUrl(url, out bool islocal, out OSHHTPHost host);
|
||||
var userdata = new UserData();
|
||||
userdata.Id = uuid;
|
||||
if (isvalid)
|
||||
{
|
||||
if (islocal)
|
||||
{
|
||||
userdata.FirstName = first;
|
||||
userdata.LastName = last;
|
||||
userdata.HomeURL = string.Empty;
|
||||
userdata.IsLocal = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
userdata.FirstName = first.Replace(" ", ".") + "." + last.Replace(" ", ".");
|
||||
userdata.HomeURL = host.URI;
|
||||
userdata.LastName = "@" + host.HostAndPort;
|
||||
userdata.IsLocal = false;
|
||||
}
|
||||
|
||||
userdata.IsUnknownUser = false;
|
||||
userdata.HasGridUserTried = true;
|
||||
m_userCacheByID.Add(uuid, userdata, 1800000);
|
||||
|
||||
untried.Remove(uuid);
|
||||
ret.Add(userdata);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_log.DebugFormat("[USER MANAGEMENT MODULE]: Unable to parse UUI {0}", uInfo.UserID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (UserData ud in untried.Values)
|
||||
{
|
||||
ud.HasGridUserTried = true;
|
||||
m_userCacheByID.Add(ud.Id, ud, 1800000);
|
||||
if (!ud.IsUnknownUser)
|
||||
ret.Add(ud);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public virtual string GetUserHomeURL(UUID userID)
|
||||
{
|
||||
if (GetUser(userID, out UserData user) && user != null)
|
||||
|
||||
Reference in New Issue
Block a user