diff options
author | Oren Hurvitz | 2015-08-07 11:34:52 +0300 |
---|---|---|
committer | Oren Hurvitz | 2015-08-07 11:34:52 +0300 |
commit | 2153a01cc7eb8667fa0c9fc76a36b178566bf444 (patch) | |
tree | 1b527915181f2a2db53c0f8760c309ffb45c036a /OpenSim/Region/ScriptEngine | |
parent | max-agent-groups support (diff) | |
download | opensim-SC_OLD-2153a01cc7eb8667fa0c9fc76a36b178566bf444.zip opensim-SC_OLD-2153a01cc7eb8667fa0c9fc76a36b178566bf444.tar.gz opensim-SC_OLD-2153a01cc7eb8667fa0c9fc76a36b178566bf444.tar.bz2 opensim-SC_OLD-2153a01cc7eb8667fa0c9fc76a36b178566bf444.tar.xz |
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.
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 1c404bb..123f8ca 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -2053,47 +2053,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2053 | CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); | 2053 | CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); |
2054 | m_host.AddScriptLPS(1); | 2054 | m_host.AddScriptLPS(1); |
2055 | 2055 | ||
2056 | if (lastname.Contains("@")) | 2056 | IUserManagement userManager = World.RequestModuleInterface<IUserManagement>(); |
2057 | if (userManager == null) | ||
2057 | { | 2058 | { |
2058 | String realFirstName; String realLastName; String serverURI; | 2059 | OSSLShoutError("osAvatarName2Key: UserManagement module not available"); |
2060 | return string.Empty; | ||
2061 | } | ||
2062 | |||
2063 | // Check if the user is already cached | ||
2064 | |||
2065 | UUID userID = userManager.GetUserIdByName(firstname, lastname); | ||
2066 | if (userID != UUID.Zero) | ||
2067 | return userID.ToString(); | ||
2059 | 2068 | ||
2060 | realFirstName = firstname.Split('.')[0]; | 2069 | // Query for the user |
2061 | realLastName = firstname.Split('.')[1]; | ||
2062 | serverURI = new Uri("http://" + lastname.Replace("@", "")).ToString(); | ||
2063 | 2070 | ||
2071 | String realFirstName; String realLastName; String serverURI; | ||
2072 | if (Util.ParseForeignAvatarName(firstname, lastname, out realFirstName, out realLastName, out serverURI)) | ||
2073 | { | ||
2064 | try | 2074 | try |
2065 | { | 2075 | { |
2066 | UserAgentServiceConnector userConnection = new UserAgentServiceConnector(serverURI, true); | 2076 | UserAgentServiceConnector userConnection = new UserAgentServiceConnector(serverURI, true); |
2067 | 2077 | ||
2068 | if (userConnection != null) | 2078 | if (userConnection != null) |
2069 | { | 2079 | { |
2070 | UUID ruserid = userConnection.GetUUID(realFirstName, realLastName); | 2080 | userID = userConnection.GetUUID(realFirstName, realLastName); |
2071 | 2081 | if (userID != UUID.Zero) | |
2072 | if (ruserid != null) | ||
2073 | { | 2082 | { |
2074 | IUserManagement userManager = m_ScriptEngine.World.RequestModuleInterface<IUserManagement>(); | 2083 | userManager.AddUser(userID, realFirstName, realLastName, serverURI); |
2075 | 2084 | return userID.ToString(); | |
2076 | if (userManager != null) | ||
2077 | { | ||
2078 | //Use the HomeURI from the script to get user infos and then ask the remote gridserver for the real HomeURI. | ||
2079 | userManager.AddUser(ruserid, realFirstName, realLastName, serverURI); | ||
2080 | serverURI = userManager.GetUserServerURL(ruserid, "HomeURI"); | ||
2081 | userManager.AddUser(ruserid, realFirstName, realLastName, serverURI); | ||
2082 | |||
2083 | return ruserid.ToString(); | ||
2084 | } | ||
2085 | } | 2085 | } |
2086 | } | 2086 | } |
2087 | } | 2087 | } |
2088 | catch (Exception osAvatarException) | 2088 | catch (Exception /*e*/) |
2089 | { | 2089 | { |
2090 | //m_log.Warn("[osAvatarName2Key] UserAgentServiceConnector - Unable to connect to destination grid\n" + osAvatarException.Message); | 2090 | // m_log.Warn("[osAvatarName2Key] UserAgentServiceConnector - Unable to connect to destination grid ", e); |
2091 | } | 2091 | } |
2092 | } | 2092 | } |
2093 | else | 2093 | else |
2094 | { | 2094 | { |
2095 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname); | 2095 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname); |
2096 | if (account != null) return account.PrincipalID.ToString(); | 2096 | if (account != null) |
2097 | return account.PrincipalID.ToString(); | ||
2097 | } | 2098 | } |
2098 | 2099 | ||
2099 | return UUID.Zero.ToString(); | 2100 | return UUID.Zero.ToString(); |