From 181b1ad82b0ec5ca6e1ef107020a81e961f4da56 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 4 Dec 2016 23:02:40 +0000 Subject: HG: fix the never ending avatar confirmation when 2 users from same grid made friendship on another grid --- .../CoreModules/Avatar/Friends/HGFriendsModule.cs | 42 +++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index 27b7376..9954749 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -337,7 +337,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (UUID.TryParse(friendID, out id)) 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) @@ -456,6 +456,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { // local grid users m_log.DebugFormat("[HGFRIENDS MODULE]: Users are both local"); + DeletePreviousHGRelations(agentID, friendID); base.StoreFriendships(agentID, friendID); 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) { Boolean agentIsLocal = true; -- cgit v1.1