diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | 100 |
1 files changed, 52 insertions, 48 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 37292d6..2ad30a0 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -423,58 +423,62 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
423 | AddUser(uuid, profileURL + ";" + first + " " + last); | 423 | AddUser(uuid, profileURL + ";" + first + " " + last); |
424 | } | 424 | } |
425 | 425 | ||
426 | public void AddUser(UUID id, string creatorData) | 426 | public void AddUser (UUID id, string creatorData) |
427 | { | 427 | { |
428 | lock (m_UserCache) | 428 | UserData oldUser; |
429 | { | 429 | //lock the whole block - prevent concurrent update |
430 | if (m_UserCache.ContainsKey(id)) | 430 | lock (m_UserCache) { |
431 | return; | 431 | m_UserCache.TryGetValue (id, out oldUser); |
432 | } | 432 | if (oldUser != null) { |
433 | 433 | if (creatorData == null || creatorData == String.Empty) { | |
434 | // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, craetorData {1}", id, creatorData); | 434 | //ignore updates without creator data |
435 | 435 | return; | |
436 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id); | 436 | } |
437 | 437 | //try update unknown users | |
438 | if (account != null) | 438 | //and creator's home URL's |
439 | { | 439 | if ((oldUser.FirstName == "Unknown" && !creatorData.Contains ("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith (oldUser.HomeURL))) { |
440 | AddUser(id, account.FirstName, account.LastName); | 440 | m_UserCache.Remove (id); |
441 | } | 441 | // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData,oldUser.HomeURL); |
442 | else | 442 | } else { |
443 | { | 443 | //we have already a valid user within the cache |
444 | UserData user = new UserData(); | 444 | return; |
445 | user.Id = id; | ||
446 | user.Flags = -1; | ||
447 | user.Created = -1; | ||
448 | |||
449 | if (creatorData != null && creatorData != string.Empty) | ||
450 | { | ||
451 | //creatorData = <endpoint>;<name> | ||
452 | |||
453 | string[] parts = creatorData.Split(';'); | ||
454 | if (parts.Length >= 1) | ||
455 | { | ||
456 | user.HomeURL = parts[0]; | ||
457 | try | ||
458 | { | ||
459 | Uri uri = new Uri(parts[0]); | ||
460 | user.LastName = "@" + uri.Authority; | ||
461 | } | ||
462 | catch (UriFormatException) | ||
463 | { | ||
464 | m_log.DebugFormat("[SCENE]: Unable to parse Uri {0}", parts[0]); | ||
465 | user.LastName = "@unknown"; | ||
466 | } | ||
467 | } | 445 | } |
468 | if (parts.Length >= 2) | ||
469 | user.FirstName = parts[1].Replace(' ', '.'); | ||
470 | } | 446 | } |
471 | else | 447 | // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData); |
472 | { | 448 | |
473 | user.FirstName = "Unknown"; | 449 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount (m_Scenes[0].RegionInfo.ScopeID, id); |
474 | user.LastName = "User"; | 450 | |
451 | if (account != null) { | ||
452 | AddUser (id, account.FirstName, account.LastName); | ||
453 | } else { | ||
454 | UserData user = new UserData (); | ||
455 | user.Id = id; | ||
456 | user.Flags = -1; | ||
457 | user.Created = -1; | ||
458 | |||
459 | if (creatorData != null && creatorData != string.Empty) { | ||
460 | //creatorData = <endpoint>;<name> | ||
461 | |||
462 | string[] parts = creatorData.Split (';'); | ||
463 | if (parts.Length >= 1) { | ||
464 | user.HomeURL = parts[0]; | ||
465 | try { | ||
466 | Uri uri = new Uri (parts[0]); | ||
467 | user.LastName = "@" + uri.Authority; | ||
468 | } catch (UriFormatException) { | ||
469 | m_log.DebugFormat ("[SCENE]: Unable to parse Uri {0}", parts[0]); | ||
470 | user.LastName = "@unknown"; | ||
471 | } | ||
472 | } | ||
473 | if (parts.Length >= 2) | ||
474 | user.FirstName = parts[1].Replace (' ', '.'); | ||
475 | } else { | ||
476 | user.FirstName = "Unknown"; | ||
477 | user.LastName = "User"; | ||
478 | } | ||
479 | |||
480 | AddUserInternal (user); | ||
475 | } | 481 | } |
476 | |||
477 | AddUserInternal(user); | ||
478 | } | 482 | } |
479 | } | 483 | } |
480 | 484 | ||