HG: fix the never ending avatar confirmation when 2 users from same grid made friendship on another grid

melanie
UbitUmarov 2016-12-04 23:02:40 +00:00
parent 51104be6d4
commit 181b1ad82b
1 changed files with 41 additions and 1 deletions

View File

@ -337,7 +337,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (UUID.TryParse(friendID, out id)) if (UUID.TryParse(friendID, out id))
return base.FriendshipMessage(friendID); return base.FriendshipMessage(friendID);
return "Please confirm this friendship you made while you were away."; return "Please confirm this friendship you made while you where on another HG grid";
} }
protected override FriendInfo GetFriend(FriendInfo[] friends, UUID friendID) protected override FriendInfo GetFriend(FriendInfo[] friends, UUID friendID)
@ -456,6 +456,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
{ {
// local grid users // local grid users
m_log.DebugFormat("[HGFRIENDS MODULE]: Users are both local"); m_log.DebugFormat("[HGFRIENDS MODULE]: Users are both local");
DeletePreviousHGRelations(agentID, friendID);
base.StoreFriendships(agentID, friendID); base.StoreFriendships(agentID, friendID);
return; return;
} }
@ -624,6 +625,45 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
} }
} }
private void DeletePreviousHGRelations(UUID a1, UUID a2)
{
// Delete any previous friendship relations
FriendInfo[] finfos = null;
finfos = GetFriendsFromCache(a1);
if (finfos != null)
{
foreach (FriendInfo f in finfos)
{
if (f.TheirFlags == -1)
{
if (f.Friend.StartsWith(a2.ToString()))
{
FriendsService.Delete(a1, f.Friend);
// and also the converse
FriendsService.Delete(f.Friend, a1.ToString());
}
}
}
}
finfos = GetFriendsFromCache(a1);
if (finfos != null)
{
foreach (FriendInfo f in finfos)
{
if (f.TheirFlags == -1)
{
if (f.Friend.StartsWith(a1.ToString()))
{
FriendsService.Delete(a2, f.Friend);
// and also the converse
FriendsService.Delete(f.Friend, a2.ToString());
}
}
}
}
}
protected override bool DeleteFriendship(UUID agentID, UUID exfriendID) protected override bool DeleteFriendship(UUID agentID, UUID exfriendID)
{ {
Boolean agentIsLocal = true; Boolean agentIsLocal = true;