From 1f4d3d35822c5ad3dbdd5f363014f1bf9afebdc6 Mon Sep 17 00:00:00 2001 From: Snoopy Pfeffer Date: Wed, 11 Apr 2012 18:52:07 +0200 Subject: HGFriendsModule: Added optional user level based restriction to send friendship invitations to foreign users. --- .../CoreModules/Avatar/Friends/HGFriendsModule.cs | 24 ++++++++++++++++++---- bin/config-include/GridCommon.ini.example | 4 ++++ bin/config-include/StandaloneCommon.ini.example | 4 ++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index ddb6a71..f8fbbbb 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -50,6 +50,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private int m_levelHGFriends = 0; + IUserManagement m_uMan; public IUserManagement UserManagementModule { @@ -95,6 +97,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends IConfig friendsConfig = config.Configs["HGFriendsModule"]; if (friendsConfig != null) { + m_levelHGFriends = friendsConfig.GetInt("LevelHGFriends", 0); + // TODO: read in all config variables pertaining to // HG friendship permissions } @@ -126,10 +130,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends UUID principalID = new UUID(im.fromAgentID); UUID friendID = new UUID(im.toAgentID); - // TODO: CHECK IF friendID is foreigner and if principalID has the permission - // to request these kinds of friendships. If not, return immediately. - // Maybe you want to let the client know too with - // client.SendAlertMessage + // Check if friendID is foreigner and if principalID has the permission + // to request friendships with foreigners. If not, return immediately. + if (!UserManagementModule.IsLocalGridUser(friendID)) + { + ScenePresence avatar = null; + client.Scene.TryGetScenePresence(principalID, out avatar); + + if (avatar == null) + return; + + if (avatar.UserLevel < m_levelHGFriends) + { + client.SendAgentAlertMessage("Unable to send friendship invitation to foreigner. Insufficient permissions.", false); + return; + } + } } base.OnInstantMessage(client, im); diff --git a/bin/config-include/GridCommon.ini.example b/bin/config-include/GridCommon.ini.example index fa6f525..8d7f6fc 100644 --- a/bin/config-include/GridCommon.ini.example +++ b/bin/config-include/GridCommon.ini.example @@ -137,6 +137,10 @@ ;; uncomment the next line. You may want to do this on sims that have licensed content. ; OutboundPermission = False +[HGFriendsModule] + ; User level required to be able to send friendship invitations to foreign users + ;LevelHGFriends = 0; + [UserAgentService] ; ; === HG ONLY === diff --git a/bin/config-include/StandaloneCommon.ini.example b/bin/config-include/StandaloneCommon.ini.example index 8fe64df..e4bc548 100644 --- a/bin/config-include/StandaloneCommon.ini.example +++ b/bin/config-include/StandaloneCommon.ini.example @@ -61,6 +61,10 @@ ;; uncomment the next line. You may want to do this on sims that have licensed content. ; OutboundPermission = False +[HGFriendsModule] + ; User level required to be able to send friendship invitations to foreign users + ;LevelHGFriends = 0; + [GridService] ;; For in-memory region storage (default) StorageProvider = "OpenSim.Data.Null.dll:NullRegionData" -- cgit v1.1