mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 10:15:33 +08:00
More on HG Friends. Added Delete(string, string) across the board. Added security to friendship identifiers so that they can safely be deleted across worlds. Had to change Get(string) to use LIKE because the secret in the identifier is not always known -- affects only HG visitors. BOTTOM LINE SO FAR: HG friendships established and deleted safely across grids, local rights working but not (yet?) being transmitted back.
This commit is contained in:
@@ -91,6 +91,9 @@ namespace OpenSim.Server.Handlers.Friends
|
||||
case "deletefriend":
|
||||
return DeleteFriend(request);
|
||||
|
||||
case "deletefriend_string":
|
||||
return DeleteFriendString(request);
|
||||
|
||||
}
|
||||
m_log.DebugFormat("[FRIENDS HANDLER]: unknown method {0} request {1}", method.Length, method);
|
||||
}
|
||||
@@ -184,7 +187,25 @@ namespace OpenSim.Server.Handlers.Friends
|
||||
else
|
||||
return FailureResult();
|
||||
}
|
||||
|
||||
|
||||
byte[] DeleteFriendString(Dictionary<string, object> request)
|
||||
{
|
||||
string principalID = string.Empty;
|
||||
if (request.ContainsKey("PRINCIPALID"))
|
||||
principalID = request["PRINCIPALID"].ToString();
|
||||
else
|
||||
m_log.WarnFormat("[FRIENDS HANDLER]: no principalID in request to delete friend");
|
||||
string friend = string.Empty;
|
||||
if (request.ContainsKey("FRIEND"))
|
||||
friend = request["FRIEND"].ToString();
|
||||
|
||||
bool success = m_FriendsService.Delete(principalID, friend);
|
||||
if (success)
|
||||
return SuccessResult();
|
||||
else
|
||||
return FailureResult();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Misc
|
||||
|
||||
@@ -88,6 +88,8 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
||||
case "newfriendship":
|
||||
return NewFriendship(request);
|
||||
|
||||
case "deletefriendship":
|
||||
return DeleteFriendship(request);
|
||||
}
|
||||
m_log.DebugFormat("[HGFRIENDS HANDLER]: unknown method {0} request {1}", method.Length, method);
|
||||
}
|
||||
@@ -143,11 +145,21 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
||||
|
||||
// OK, can proceed
|
||||
FriendInfo friend = new FriendInfo(request);
|
||||
UUID friendID;
|
||||
string tmp = string.Empty;
|
||||
if (!Util.ParseUniversalUserIdentifier(friend.Friend, out friendID, out tmp, out tmp, out tmp, out tmp))
|
||||
return FailureResult();
|
||||
|
||||
m_log.DebugFormat("[HGFRIENDS HANDLER]: New friendship {0} {1}", friend.PrincipalID, friend.Friend);
|
||||
|
||||
// If the friendship already exists, return fail
|
||||
FriendInfo[] finfos = m_FriendsService.GetFriends(friend.PrincipalID);
|
||||
foreach (FriendInfo finfo in finfos)
|
||||
if (finfo.Friend.StartsWith(friendID.ToString()))
|
||||
return FailureResult();
|
||||
|
||||
// the user needs to confirm when he gets home
|
||||
bool success = m_FriendsService.StoreFriend(friend.PrincipalID.ToString(), friend.Friend, 0);
|
||||
//if (success)
|
||||
// m_FriendsService.StoreFriend(friend.Friend, friend.PrincipalID.ToString(), 1);
|
||||
|
||||
if (success)
|
||||
return SuccessResult();
|
||||
@@ -155,6 +167,33 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
||||
return FailureResult();
|
||||
}
|
||||
|
||||
byte[] DeleteFriendship(Dictionary<string, object> request)
|
||||
{
|
||||
FriendInfo friend = new FriendInfo(request);
|
||||
string secret = string.Empty;
|
||||
if (request.ContainsKey("SECRET"))
|
||||
secret = request["SECRET"].ToString();
|
||||
|
||||
if (secret == string.Empty)
|
||||
return FailureResult();
|
||||
|
||||
FriendInfo[] finfos = m_FriendsService.GetFriends(friend.PrincipalID);
|
||||
foreach (FriendInfo finfo in finfos)
|
||||
{
|
||||
// We check the secret here
|
||||
if (finfo.Friend.StartsWith(friend.Friend) && finfo.Friend.EndsWith(secret))
|
||||
{
|
||||
m_log.DebugFormat("[HGFRIENDS HANDLER]: Delete friendship {0} {1}", friend.PrincipalID, friend.Friend);
|
||||
m_FriendsService.Delete(friend.PrincipalID, finfo.Friend);
|
||||
m_FriendsService.Delete(finfo.Friend, friend.PrincipalID.ToString());
|
||||
|
||||
return SuccessResult();
|
||||
}
|
||||
}
|
||||
|
||||
return FailureResult();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Misc
|
||||
|
||||
Reference in New Issue
Block a user