Add test for adding a friend whilst online
parent
80bea38c07
commit
8f7f03e7fd
|
@ -56,13 +56,21 @@ namespace OpenSim.Data.Null
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public FriendsData[] GetFriends(string userID)
|
public FriendsData[] GetFriends(string userID)
|
||||||
{
|
{
|
||||||
List<FriendsData> lst = m_Data.FindAll(delegate (FriendsData fdata)
|
List<FriendsData> lst = m_Data.FindAll(fdata =>
|
||||||
{
|
{
|
||||||
return fdata.PrincipalID == userID.ToString();
|
return fdata.PrincipalID == userID.ToString();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (lst != null)
|
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 lst.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
return new FriendsData[0];
|
return new FriendsData[0];
|
||||||
}
|
}
|
||||||
|
|
|
@ -578,9 +578,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||||
|
|
||||||
private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders)
|
private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> 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
|
// Update the local cache
|
||||||
RefetchFriends(client);
|
RefetchFriends(client);
|
||||||
|
@ -590,7 +595,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||||
//
|
//
|
||||||
|
|
||||||
// Try Local
|
// Try Local
|
||||||
if (LocalFriendshipApproved(agentID, client.Name, friendID))
|
if (LocalFriendshipApproved(client.AgentId, client.Name, friendID))
|
||||||
{
|
{
|
||||||
client.SendAgentOnline(new UUID[] { friendID });
|
client.SendAgentOnline(new UUID[] { friendID });
|
||||||
return;
|
return;
|
||||||
|
@ -604,7 +609,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||||
if (friendSession != null)
|
if (friendSession != null)
|
||||||
{
|
{
|
||||||
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
|
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 });
|
client.SendAgentOnline(new UUID[] { friendID });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -871,7 +876,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update loca cache only
|
/// Update local cache only
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userID"></param>
|
/// <param name="userID"></param>
|
||||||
/// <param name="friendID"></param>
|
/// <param name="friendID"></param>
|
||||||
|
|
|
@ -70,9 +70,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests
|
||||||
UUID userId = TestHelpers.ParseTail(0x1);
|
UUID userId = TestHelpers.ParseTail(0x1);
|
||||||
|
|
||||||
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
|
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
|
||||||
|
|
||||||
Assert.That(((TestClient)sp.ControllingClient).OfflineNotificationsReceived.Count, Is.EqualTo(0));
|
Assert.That(((TestClient)sp.ControllingClient).OfflineNotificationsReceived.Count, Is.EqualTo(0));
|
||||||
Assert.That(((TestClient)sp.ControllingClient).OnlineNotificationsReceived.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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -33,6 +33,20 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
{
|
{
|
||||||
public interface IFriendsModule
|
public interface IFriendsModule
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Add a friend for the given user.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// 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.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="client"></param>
|
||||||
|
/// <param name="friendID"></param>
|
||||||
|
void AddFriend(IClientAPI client, UUID friendID);
|
||||||
|
|
||||||
uint GetFriendPerms(UUID PrincipalID, UUID FriendID);
|
uint GetFriendPerms(UUID PrincipalID, UUID FriendID);
|
||||||
bool SendFriendsOnlineIfNeeded(IClientAPI client);
|
bool SendFriendsOnlineIfNeeded(IClientAPI client);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue