Fix scope support to get friends list names across co-hosted grids
parent
24aa13239c
commit
d781742d8e
|
@ -70,7 +70,7 @@ namespace OpenSim.Capabilities.Handlers
|
|||
return new byte[0];
|
||||
}
|
||||
|
||||
Dictionary<UUID,string> names = m_UserManagement.GetUsersNames(ids);
|
||||
Dictionary<UUID,string> names = m_UserManagement.GetUsersNames(ids, UUID.Zero);
|
||||
|
||||
OSDMap osdReply = new OSDMap();
|
||||
OSDArray agents = new OSDArray();
|
||||
|
|
|
@ -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<IUserManagement>();
|
||||
m_userAccountService = m_Scene.RequestModuleInterface<IUserAccountService>();
|
||||
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<UUID,string> names = m_UserManager.GetUsersNames(ids);
|
||||
|
||||
Dictionary<UUID,string> 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<UUID,string> 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);;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -485,7 +485,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
|||
return user.FirstName + " " + user.LastName;
|
||||
}
|
||||
|
||||
public virtual Dictionary<UUID,string> GetUsersNames(string[] ids)
|
||||
public virtual Dictionary<UUID,string> GetUsersNames(string[] ids, UUID scopeID)
|
||||
{
|
||||
Dictionary<UUID,string> ret = new Dictionary<UUID,string>();
|
||||
if(m_Scenes.Count <= 0)
|
||||
|
@ -528,7 +528,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
|||
|
||||
// try user account service
|
||||
List<UserAccount> accounts = m_Scenes[0].UserAccountService.GetUserAccounts(
|
||||
m_Scenes[0].RegionInfo.ScopeID, missing);
|
||||
scopeID, missing);
|
||||
|
||||
if(accounts.Count != 0)
|
||||
{
|
||||
|
|
|
@ -164,6 +164,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
|
|||
|
||||
public override List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs)
|
||||
{
|
||||
m_log.DebugFormat("[REMOTE USER ACCOUNTS]: Request for {0} records", IDs.Count);
|
||||
List<UserAccount> accs = new List<UserAccount>();
|
||||
List<string> missing = new List<string>();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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<UUID,string> GetUsersNames(string[] ids);
|
||||
Dictionary<UUID,string> GetUsersNames(string[] ids, UUID scopeID);
|
||||
|
||||
/// <summary>
|
||||
/// Get user ID by the given name.
|
||||
|
|
|
@ -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<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs)
|
||||
{
|
||||
// do it one at a time db access should be fast, so no need to break its api
|
||||
List<UserAccount> accs = new List<UserAccount>();
|
||||
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<UserAccount>(ret.Select((x) => MakeUserAccount(x)));
|
||||
}
|
||||
|
||||
public void InvalidateCache(UUID userID)
|
||||
|
|
Loading…
Reference in New Issue