From d781742d8e966bedb7ac0f9e637003d090a35375 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 7 Aug 2019 17:58:08 +0100 Subject: Fix scope support to get friends list names across co-hosted grids --- .../GetDisplayNames/GetDisplayNamesHandler.cs | 2 +- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 28 ++++++++++++++++------ .../UserManagement/UserManagementModule.cs | 4 ++-- .../RemoteUserAccountServiceConnector.cs | 7 ++++++ OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 2 ++ OpenSim/Services/Interfaces/IUserManagement.cs | 2 +- .../UserAccountService/UserAccountService.cs | 12 +++------- 7 files changed, 37 insertions(+), 20 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs b/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs index 41cfdb6..199eef1 100644 --- a/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetDisplayNames/GetDisplayNamesHandler.cs @@ -70,7 +70,7 @@ namespace OpenSim.Capabilities.Handlers return new byte[0]; } - Dictionary names = m_UserManagement.GetUsersNames(ids); + Dictionary names = m_UserManagement.GetUsersNames(ids, UUID.Zero); OSDMap osdReply = new OSDMap(); OSDArray agents = new OSDArray(); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index ea68581..9f1ea4d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -93,6 +93,7 @@ namespace OpenSim.Region.ClientStack.Linden private Scene m_Scene; private UUID m_AgentID; + private UUID m_scopeID; private Caps m_HostCapsObj; private ModelCost m_ModelCost; @@ -128,6 +129,7 @@ namespace OpenSim.Region.ClientStack.Linden private bool m_AllowCapHomeLocation = true; private bool m_AllowCapGroupMemberData = true; private IUserManagement m_UserManager; + private IUserAccountService m_userAccountService; private enum FileAgentInventoryState : int @@ -201,9 +203,13 @@ namespace OpenSim.Region.ClientStack.Linden m_assetService = m_Scene.AssetService; m_regionName = m_Scene.RegionInfo.RegionName; m_UserManager = m_Scene.RequestModuleInterface(); + m_userAccountService = m_Scene.RequestModuleInterface(); if (m_UserManager == null) m_log.Error("[CAPS]: GetDisplayNames disabled because user management component not found"); + UserAccount account = m_userAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, m_AgentID); + m_scopeID = account.ScopeID; + RegisterHandlers(); AddNewInventoryItem = m_Scene.AddUploadedInventoryItem; @@ -1943,11 +1949,12 @@ namespace OpenSim.Region.ClientStack.Linden NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); string[] ids = query.GetValues("ids"); + m_log.DebugFormat("[DISPLAYNAMES]: Request for {0} names", ids.Length); - Dictionary names = m_UserManager.GetUsersNames(ids); - + Dictionary names = m_UserManager.GetUsersNames(ids, m_scopeID); StringBuilder lsl = LLSDxmlEncode.Start(names.Count * 256 + 256); LLSDxmlEncode.AddMap(lsl); + int ct = 0; if(names.Count == 0) LLSDxmlEncode.AddEmptyArray("agents", lsl); else @@ -1956,13 +1963,18 @@ namespace OpenSim.Region.ClientStack.Linden foreach (KeyValuePair kvp in names) { + string[] parts = kvp.Value.Split(new char[] {' '}); + string fullname = kvp.Value; + if (string.IsNullOrEmpty(kvp.Value)) - continue; + { + parts = new string[] {"(hippos)", ""}; + fullname = "(hippos)"; + } + if(kvp.Key == UUID.Zero) continue; - string[] parts = kvp.Value.Split(new char[] {' '}); - // dont tell about unknown users, we can't send them back on Bad either if(parts[0] == "Unknown") continue; @@ -1970,18 +1982,20 @@ namespace OpenSim.Region.ClientStack.Linden LLSDxmlEncode.AddMap(lsl); LLSDxmlEncode.AddElem("display_name_next_update", DateTime.UtcNow.AddDays(8), lsl); LLSDxmlEncode.AddElem("display_name_expires", DateTime.UtcNow.AddMonths(1), lsl); - LLSDxmlEncode.AddElem("display_name", kvp.Value, lsl); + LLSDxmlEncode.AddElem("display_name", fullname, lsl); LLSDxmlEncode.AddElem("legacy_first_name", parts[0], lsl); LLSDxmlEncode.AddElem("legacy_last_name", parts[1], lsl); - LLSDxmlEncode.AddElem("username", kvp.Value, lsl); + LLSDxmlEncode.AddElem("username", fullname, lsl); LLSDxmlEncode.AddElem("id", kvp.Key, lsl); LLSDxmlEncode.AddElem("is_display_name_default", true, lsl); LLSDxmlEncode.AddEndMap(lsl); + ct++; } LLSDxmlEncode.AddEndArray(lsl); } LLSDxmlEncode.AddEndMap(lsl); + m_log.DebugFormat("[DISPLAYNAMES]: Returned {0} names", ct); return LLSDxmlEncode.End(lsl);; } } diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index c82d45a..40b83f3 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -485,7 +485,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement return user.FirstName + " " + user.LastName; } - public virtual Dictionary GetUsersNames(string[] ids) + public virtual Dictionary GetUsersNames(string[] ids, UUID scopeID) { Dictionary ret = new Dictionary(); if(m_Scenes.Count <= 0) @@ -528,7 +528,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement // try user account service List accounts = m_Scenes[0].UserAccountService.GetUserAccounts( - m_Scenes[0].RegionInfo.ScopeID, missing); + scopeID, missing); if(accounts.Count != 0) { diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index b510d0a..9574d08 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs @@ -164,6 +164,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts public override List GetUserAccounts(UUID scopeID, List IDs) { + m_log.DebugFormat("[REMOTE USER ACCOUNTS]: Request for {0} records", IDs.Count); List accs = new List(); List missing = new List(); @@ -177,9 +178,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { account = m_Cache.Get(uuid, out inCache); if (inCache) + { accs.Add(account); + m_log.DebugFormat("[REMOTE USER ACCOUNTS]: Found in cache: {0}, is null {1}", uuid, account == null); + } else + { missing.Add(id); + } } } @@ -198,6 +204,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts } } } + m_log.DebugFormat("[REMOTE USER ACCOUNTS]: returned {0} records", accs.Count); return accs; } diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index dd4f974..5a38501 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -608,6 +608,8 @@ namespace OpenSim.Region.ScriptEngine.Shared size += 8; else if (o is double) size += 16; + else if (o is list) + size += ((list)o).Size; else throw new Exception("Unknown type in List.Size: " + o.GetType().ToString()); } diff --git a/OpenSim/Services/Interfaces/IUserManagement.cs b/OpenSim/Services/Interfaces/IUserManagement.cs index 3bdf86d..39268c0 100644 --- a/OpenSim/Services/Interfaces/IUserManagement.cs +++ b/OpenSim/Services/Interfaces/IUserManagement.cs @@ -42,7 +42,7 @@ namespace OpenSim.Services.Interfaces string GetUserUUI(UUID uuid); bool GetUserUUI(UUID userID, out string uui); string GetUserServerURL(UUID uuid, string serverType); - Dictionary GetUsersNames(string[] ids); + Dictionary GetUsersNames(string[] ids, UUID scopeID); /// /// Get user ID by the given name. diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 24f436d..9ac8418 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -26,6 +26,7 @@ */ using System; +using System.Linq; using System.Collections.Generic; using System.Reflection; using log4net; @@ -292,15 +293,8 @@ namespace OpenSim.Services.UserAccountService public List GetUserAccounts(UUID scopeID, List IDs) { - // do it one at a time db access should be fast, so no need to break its api - List accs = new List(); - UUID uuid = UUID.Zero; - foreach(string id in IDs) - { - if (UUID.TryParse(id, out uuid) && uuid != UUID.Zero) - accs.Add(GetUserAccount(scopeID, uuid)); - } - return accs; + UserAccountData[] ret = m_Database.GetUsersWhere(scopeID, "PrincipalID in ('" + String.Join("', '", IDs) + "')"); + return new List(ret.Select((x) => MakeUserAccount(x))); } public void InvalidateCache(UUID userID) -- cgit v1.1