HG Friends bug fix: connector was shrinking principalID to UUID.

bulletsim
Diva Canto 2011-06-02 07:26:40 -07:00
parent c13acdf5a1
commit f2f30a7890
2 changed files with 28 additions and 15 deletions

View File

@ -160,9 +160,9 @@ namespace OpenSim.Server.Handlers.Friends
byte[] StoreFriend(Dictionary<string, object> request) byte[] StoreFriend(Dictionary<string, object> request)
{ {
FriendInfo friend = new FriendInfo(request); string principalID = string.Empty, friend = string.Empty; int flags = 0;
FromKeyValuePairs(request, out principalID, out friend, out flags);
bool success = m_FriendsService.StoreFriend(friend.PrincipalID.ToString(), friend.Friend, friend.MyFlags); bool success = m_FriendsService.StoreFriend(principalID, friend, flags);
if (success) if (success)
return SuccessResult(); return SuccessResult();
@ -275,6 +275,19 @@ namespace OpenSim.Server.Handlers.Friends
return ms.ToArray(); return ms.ToArray();
} }
void FromKeyValuePairs(Dictionary<string, object> kvp, out string principalID, out string friend, out int flags)
{
principalID = string.Empty;
if (kvp.ContainsKey("PrincipalID") && kvp["PrincipalID"] != null)
principalID = kvp["PrincipalID"].ToString();
friend = string.Empty;
if (kvp.ContainsKey("Friend") && kvp["Friend"] != null)
friend = kvp["Friend"].ToString();
flags = 0;
if (kvp.ContainsKey("MyFlags") && kvp["MyFlags"] != null)
Int32.TryParse(kvp["MyFlags"].ToString(), out flags);
}
#endregion #endregion
} }
} }

View File

@ -161,19 +161,8 @@ namespace OpenSim.Services.Connectors.Friends
public bool StoreFriend(string PrincipalID, string Friend, int flags) public bool StoreFriend(string PrincipalID, string Friend, int flags)
{ {
FriendInfo finfo = new FriendInfo();
try
{
finfo.PrincipalID = new UUID(PrincipalID);
}
catch
{
return false;
}
finfo.Friend = Friend;
finfo.MyFlags = flags;
Dictionary<string, object> sendData = finfo.ToKeyValuePairs(); Dictionary<string, object> sendData = ToKeyValuePairs(PrincipalID, Friend, flags);
sendData["METHOD"] = "storefriend"; sendData["METHOD"] = "storefriend";
@ -267,5 +256,16 @@ namespace OpenSim.Services.Connectors.Friends
} }
#endregion #endregion
public Dictionary<string, object> ToKeyValuePairs(string principalID, string friend, int flags)
{
Dictionary<string, object> result = new Dictionary<string, object>();
result["PrincipalID"] = principalID;
result["Friend"] = friend;
result["MyFlags"] = flags;
return result;
}
} }
} }