diff --git a/OpenSim/Data/Null/NullFriendsData.cs b/OpenSim/Data/Null/NullFriendsData.cs
index d90788a111..0a4b2426a8 100644
--- a/OpenSim/Data/Null/NullFriendsData.cs
+++ b/OpenSim/Data/Null/NullFriendsData.cs
@@ -56,13 +56,21 @@ namespace OpenSim.Data.Null
///
public FriendsData[] GetFriends(string userID)
{
- List lst = m_Data.FindAll(delegate (FriendsData fdata)
+ List lst = m_Data.FindAll(fdata =>
{
return fdata.PrincipalID == userID.ToString();
});
if (lst != null)
+ {
+ lst.ForEach(f =>
+ {
+ FriendsData f2 = m_Data.Find(candidateF2 => f.Friend == candidateF2.PrincipalID);
+ if (f2 != null) { f.Data["TheirFlags"] = f2.Data["Flags"]; }
+ });
+
return lst.ToArray();
+ }
return new FriendsData[0];
}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 375ddc2733..cc8ee5ac0c 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -578,9 +578,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders)
{
- m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", agentID, friendID);
+ m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", client.AgentId, friendID);
- StoreFriendships(agentID, friendID);
+ AddFriend(client, friendID);
+ }
+
+ public void AddFriend(IClientAPI client, UUID friendID)
+ {
+ StoreFriendships(client.AgentId, friendID);
// Update the local cache
RefetchFriends(client);
@@ -590,7 +595,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
//
// Try Local
- if (LocalFriendshipApproved(agentID, client.Name, friendID))
+ if (LocalFriendshipApproved(client.AgentId, client.Name, friendID))
{
client.SendAgentOnline(new UUID[] { friendID });
return;
@@ -604,7 +609,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (friendSession != null)
{
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
- m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID);
+ m_FriendsSimConnector.FriendshipApproved(region, client.AgentId, client.Name, friendID);
client.SendAgentOnline(new UUID[] { friendID });
}
}
@@ -871,7 +876,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
}
///
- /// Update loca cache only
+ /// Update local cache only
///
///
///
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
index b52093a98d..3ad691a519 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
@@ -70,9 +70,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests
UUID userId = TestHelpers.ParseTail(0x1);
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
-
+
Assert.That(((TestClient)sp.ControllingClient).OfflineNotificationsReceived.Count, Is.EqualTo(0));
Assert.That(((TestClient)sp.ControllingClient).OnlineNotificationsReceived.Count, Is.EqualTo(0));
}
+
+ [Test]
+ public void TestAddFriendWhileOnline()
+ {
+ TestHelpers.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ UUID userId = TestHelpers.ParseTail(0x1);
+ UUID user2Id = TestHelpers.ParseTail(0x2);
+
+ ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
+ ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, user2Id);
+
+ // This friendship is currently only one-way, which might be pathalogical in Second Life.
+ m_fm.AddFriend(sp.ControllingClient, user2Id);
+
+ Assert.That(((TestClient)sp.ControllingClient).OfflineNotificationsReceived.Count, Is.EqualTo(0));
+ Assert.That(((TestClient)sp.ControllingClient).OnlineNotificationsReceived.Count, Is.EqualTo(1));
+ }
}
}
\ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
index d4a6857188..8143164283 100644
--- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
@@ -33,6 +33,20 @@ namespace OpenSim.Region.Framework.Interfaces
{
public interface IFriendsModule
{
+ ///
+ /// Add a friend for the given user.
+ ///
+ ///
+ /// This is a one-way friendship. To make a two way friendship you will need to call this again with the
+ /// client and friend reversed.
+ ///
+ /// Ultimately, it would be more useful to take in a user account here rather than having to have a user
+ /// present in the scene.
+ ///
+ ///
+ ///
+ void AddFriend(IClientAPI client, UUID friendID);
+
uint GetFriendPerms(UUID PrincipalID, UUID FriendID);
bool SendFriendsOnlineIfNeeded(IClientAPI client);
}