Have osAvatarName2Key check the cache first, even for foreign users
Another change: removed the second call to userManager.AddUser(). UserManagementModule won't modify an existing record.0.8.2-post-fixes
parent
f218cbd29d
commit
2153a01cc7
|
@ -2744,7 +2744,9 @@ namespace OpenSim.Framework
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Universal User Identifiers
|
#region Universal User Identifiers
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Attempts to parse a UUI into its components: UUID, name and URL.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">uuid[;endpoint[;first last[;secret]]]</param>
|
/// <param name="value">uuid[;endpoint[;first last[;secret]]]</param>
|
||||||
/// <param name="uuid">the uuid part</param>
|
/// <param name="uuid">the uuid part</param>
|
||||||
|
@ -2779,6 +2781,27 @@ namespace OpenSim.Framework
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For foreign avatars, extracts their original name and Server URL from their First Name and Last Name.
|
||||||
|
/// </summary>
|
||||||
|
public static bool ParseForeignAvatarName(string firstname, string lastname,
|
||||||
|
out string realFirstName, out string realLastName, out string serverURI)
|
||||||
|
{
|
||||||
|
realFirstName = realLastName = serverURI = string.Empty;
|
||||||
|
|
||||||
|
if (!lastname.Contains("@"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!firstname.Contains("."))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
realFirstName = firstname.Split('.')[0];
|
||||||
|
realLastName = firstname.Split('.')[1];
|
||||||
|
serverURI = new Uri("http://" + lastname.Replace("@", "")).ToString();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Produces a universal (HG) system-facing identifier given the information
|
/// Produces a universal (HG) system-facing identifier given the information
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -2053,47 +2053,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key");
|
CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key");
|
||||||
m_host.AddScriptLPS(1);
|
m_host.AddScriptLPS(1);
|
||||||
|
|
||||||
if (lastname.Contains("@"))
|
IUserManagement userManager = World.RequestModuleInterface<IUserManagement>();
|
||||||
|
if (userManager == null)
|
||||||
{
|
{
|
||||||
|
OSSLShoutError("osAvatarName2Key: UserManagement module not available");
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the user is already cached
|
||||||
|
|
||||||
|
UUID userID = userManager.GetUserIdByName(firstname, lastname);
|
||||||
|
if (userID != UUID.Zero)
|
||||||
|
return userID.ToString();
|
||||||
|
|
||||||
|
// Query for the user
|
||||||
|
|
||||||
String realFirstName; String realLastName; String serverURI;
|
String realFirstName; String realLastName; String serverURI;
|
||||||
|
if (Util.ParseForeignAvatarName(firstname, lastname, out realFirstName, out realLastName, out serverURI))
|
||||||
realFirstName = firstname.Split('.')[0];
|
{
|
||||||
realLastName = firstname.Split('.')[1];
|
|
||||||
serverURI = new Uri("http://" + lastname.Replace("@", "")).ToString();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
UserAgentServiceConnector userConnection = new UserAgentServiceConnector(serverURI, true);
|
UserAgentServiceConnector userConnection = new UserAgentServiceConnector(serverURI, true);
|
||||||
|
|
||||||
if (userConnection != null)
|
if (userConnection != null)
|
||||||
{
|
{
|
||||||
UUID ruserid = userConnection.GetUUID(realFirstName, realLastName);
|
userID = userConnection.GetUUID(realFirstName, realLastName);
|
||||||
|
if (userID != UUID.Zero)
|
||||||
if (ruserid != null)
|
|
||||||
{
|
{
|
||||||
IUserManagement userManager = m_ScriptEngine.World.RequestModuleInterface<IUserManagement>();
|
userManager.AddUser(userID, realFirstName, realLastName, serverURI);
|
||||||
|
return userID.ToString();
|
||||||
if (userManager != null)
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception /*e*/)
|
||||||
{
|
{
|
||||||
//Use the HomeURI from the script to get user infos and then ask the remote gridserver for the real HomeURI.
|
// m_log.Warn("[osAvatarName2Key] UserAgentServiceConnector - Unable to connect to destination grid ", e);
|
||||||
userManager.AddUser(ruserid, realFirstName, realLastName, serverURI);
|
|
||||||
serverURI = userManager.GetUserServerURL(ruserid, "HomeURI");
|
|
||||||
userManager.AddUser(ruserid, realFirstName, realLastName, serverURI);
|
|
||||||
|
|
||||||
return ruserid.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception osAvatarException)
|
|
||||||
{
|
|
||||||
//m_log.Warn("[osAvatarName2Key] UserAgentServiceConnector - Unable to connect to destination grid\n" + osAvatarException.Message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname);
|
UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname);
|
||||||
if (account != null) return account.PrincipalID.ToString();
|
if (account != null)
|
||||||
|
return account.PrincipalID.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return UUID.Zero.ToString();
|
return UUID.Zero.ToString();
|
||||||
|
|
Loading…
Reference in New Issue