Allow update of stored entries within User Management Module-this is needed for proper work of HG friends.
See http://opensimulator.org/mantis/view.php?id=5847avinationmerge
parent
8bdd80abfa
commit
6214e6a217
|
@ -423,58 +423,62 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
|||
AddUser(uuid, profileURL + ";" + first + " " + last);
|
||||
}
|
||||
|
||||
public void AddUser(UUID id, string creatorData)
|
||||
public void AddUser (UUID id, string creatorData)
|
||||
{
|
||||
lock (m_UserCache)
|
||||
{
|
||||
if (m_UserCache.ContainsKey(id))
|
||||
return;
|
||||
}
|
||||
|
||||
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, craetorData {1}", id, creatorData);
|
||||
|
||||
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id);
|
||||
|
||||
if (account != null)
|
||||
{
|
||||
AddUser(id, account.FirstName, account.LastName);
|
||||
}
|
||||
else
|
||||
{
|
||||
UserData user = new UserData();
|
||||
user.Id = id;
|
||||
user.Flags = -1;
|
||||
user.Created = -1;
|
||||
|
||||
if (creatorData != null && creatorData != string.Empty)
|
||||
{
|
||||
//creatorData = <endpoint>;<name>
|
||||
|
||||
string[] parts = creatorData.Split(';');
|
||||
if (parts.Length >= 1)
|
||||
{
|
||||
user.HomeURL = parts[0];
|
||||
try
|
||||
{
|
||||
Uri uri = new Uri(parts[0]);
|
||||
user.LastName = "@" + uri.Authority;
|
||||
}
|
||||
catch (UriFormatException)
|
||||
{
|
||||
m_log.DebugFormat("[SCENE]: Unable to parse Uri {0}", parts[0]);
|
||||
user.LastName = "@unknown";
|
||||
}
|
||||
UserData oldUser;
|
||||
//lock the whole block - prevent concurrent update
|
||||
lock (m_UserCache) {
|
||||
m_UserCache.TryGetValue (id, out oldUser);
|
||||
if (oldUser != null) {
|
||||
if (creatorData == null || creatorData == String.Empty) {
|
||||
//ignore updates without creator data
|
||||
return;
|
||||
}
|
||||
//try update unknown users
|
||||
//and creator's home URL's
|
||||
if ((oldUser.FirstName == "Unknown" && !creatorData.Contains ("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith (oldUser.HomeURL))) {
|
||||
m_UserCache.Remove (id);
|
||||
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData,oldUser.HomeURL);
|
||||
} else {
|
||||
//we have already a valid user within the cache
|
||||
return;
|
||||
}
|
||||
if (parts.Length >= 2)
|
||||
user.FirstName = parts[1].Replace(' ', '.');
|
||||
}
|
||||
else
|
||||
{
|
||||
user.FirstName = "Unknown";
|
||||
user.LastName = "User";
|
||||
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData);
|
||||
|
||||
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount (m_Scenes[0].RegionInfo.ScopeID, id);
|
||||
|
||||
if (account != null) {
|
||||
AddUser (id, account.FirstName, account.LastName);
|
||||
} else {
|
||||
UserData user = new UserData ();
|
||||
user.Id = id;
|
||||
user.Flags = -1;
|
||||
user.Created = -1;
|
||||
|
||||
if (creatorData != null && creatorData != string.Empty) {
|
||||
//creatorData = <endpoint>;<name>
|
||||
|
||||
string[] parts = creatorData.Split (';');
|
||||
if (parts.Length >= 1) {
|
||||
user.HomeURL = parts[0];
|
||||
try {
|
||||
Uri uri = new Uri (parts[0]);
|
||||
user.LastName = "@" + uri.Authority;
|
||||
} catch (UriFormatException) {
|
||||
m_log.DebugFormat ("[SCENE]: Unable to parse Uri {0}", parts[0]);
|
||||
user.LastName = "@unknown";
|
||||
}
|
||||
}
|
||||
if (parts.Length >= 2)
|
||||
user.FirstName = parts[1].Replace (' ', '.');
|
||||
} else {
|
||||
user.FirstName = "Unknown";
|
||||
user.LastName = "User";
|
||||
}
|
||||
|
||||
AddUserInternal (user);
|
||||
}
|
||||
|
||||
AddUserInternal(user);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue