Change the permissions module to use the friend list cache already in the

friends module instead of requesting the entire friends list over the
network each time a prim is touched.
0.6.8-post-fixes
Melanie 2009-11-05 17:29:52 +00:00
parent b098572525
commit ec0d5b408a
3 changed files with 29 additions and 2 deletions

View File

@ -1114,6 +1114,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
{
((Scene)remoteClient.Scene).CommsManager.UpdateUserFriendPerms(requester, target, (uint)rights);
}
public List<FriendListItem> GetUserFriends(UUID agentID)
{
List<FriendListItem> fl;
lock (m_friendLists)
{
fl = (List<FriendListItem>)m_friendLists.Get(agentID.ToString(),
m_initialScene.GetFriendList);
}
return fl;
}
}
#endregion
}

View File

@ -144,6 +144,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
private Dictionary<string, bool> GrantVB = new Dictionary<string, bool>();
private Dictionary<string, bool> GrantJS = new Dictionary<string, bool>();
private Dictionary<string, bool> GrantYP = new Dictionary<string, bool>();
private IFriendsModule m_friendsModule = null;
#endregion
#region IRegionModule Members
@ -363,6 +365,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions
public void PostInitialise()
{
m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
if (m_friendsModule == null)
m_log.Error("[PERMISSIONS]: Friends module not found, friend permissions will not work");
else
m_log.Info("[PERMISSIONS]: Friends module found, friend permissions enabled");
}
public void Close()
@ -479,9 +487,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
protected bool IsFriendWithPerms(UUID user,UUID objectOwner)
{
if (user == UUID.Zero) return false;
if (user == UUID.Zero)
return false;
if (m_friendsModule == null)
return false;
List<FriendListItem> profile = m_friendsModule.GetUserFriends(user);
List<FriendListItem> profile = m_scene.CommsManager.GetUserFriendList(user);
foreach (FriendListItem item in profile)
{
if(item.Friend == objectOwner && (item.FriendPerms & (uint)FriendRights.CanModifyObjects) != 0)

View File

@ -27,6 +27,7 @@
using OpenMetaverse;
using OpenSim.Framework;
using System.Collections.Generic;
namespace OpenSim.Region.Framework.Interfaces
{
@ -45,5 +46,6 @@ namespace OpenSim.Region.Framework.Interfaces
/// </param>
/// <param name="offerMessage"></param>
void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage);
List<FriendListItem> GetUserFriends(UUID agentID);
}
}