From 3906a14857eb3fbef9705240763afb9af1c9e303 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Sat, 27 Feb 2010 10:24:55 -0800
Subject: Friends online notifications upon friendship now working (same sim
 only).

---
 .../Region/CoreModules/Avatar/Friends/FriendsModule.cs   |  3 +++
 .../CoreModules/Avatar/InstantMessage/PresenceModule.cs  | 16 ++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 1719447..34f14df 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -432,6 +432,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
                 GridInstantMessage im = new GridInstantMessage(client.Scene, client.AgentId, client.Name, friendID,
                     (byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, client.AgentId.ToString(), false, Vector3.Zero);
                 friendClient.SendInstantMessage(im);
+                client.SendAgentOnline(new UUID[] { friendID });
                 // we're done
                 return;
             }
@@ -442,7 +443,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
             {
                 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
                 m_FriendsSimConnector.FriendshipApproved(region, agentID, friendID);
+                client.SendAgentOnline(new UUID[] { friendID });
             }
+
         }
 
         private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders)
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
index 4e57394..bafad82 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
@@ -123,6 +123,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
                 return;
 
             IClientAPI client = (IClientAPI)sender;
+            m_log.DebugFormat("[PRESENCE MODULE]: OnlineNotification requested by {0}", client.Name);
 
             PresenceInfo[] status = PresenceService.GetAgents(args.ToArray());
 
@@ -131,10 +132,21 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
 
             foreach (PresenceInfo pi in status)
             {
+                UUID uuid = new UUID(pi.UserID);
                 if (pi.Online)
-                    online.Add(new UUID(pi.UserID));
+                {
+                    if (!online.Contains(uuid))
+                    {
+                        online.Add(uuid);
+                        if (offline.Contains(uuid))
+                            offline.Remove(uuid);
+                    }
+                }
                 else
-                    offline.Add(new UUID(pi.UserID));
+                {
+                    if (!online.Contains(uuid) && !offline.Contains(uuid))
+                        offline.Add(uuid);
+                }
             }
 
             if (online.Count > 0)
-- 
cgit v1.1