From 0517e3d439e6888a739de90286267ee2f946c8df Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 20 Aug 2016 22:44:00 +0100 Subject: Mantis #8000, don't charge for updating classifieds. Thanks, Cinder! Signed-off-by: Melanie Thielker --- .../Avatar/UserProfiles/UserProfileModule.cs | 52 ++++++++++++---------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 145f3db..61835f9 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs @@ -31,6 +31,7 @@ using System.Text; using System.Collections; using System.Collections.Generic; using System.Globalization; +using System.Linq; using System.Net; using System.Net.Sockets; using System.Reflection; @@ -458,36 +459,43 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles int queryclassifiedPrice, IClientAPI remoteClient) { Scene s = (Scene)remoteClient.Scene; - IMoneyModule money = s.RequestModuleInterface(); - - if (money != null) - { - if (!money.AmountCovered(remoteClient.AgentId, queryclassifiedPrice)) - { - remoteClient.SendAgentAlertMessage("You do not have enough money to create requested classified.", false); - return; - } - money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, MoneyTransactionType.ClassifiedCharge); - } - - UserClassifiedAdd ad = new UserClassifiedAdd(); - Vector3 pos = remoteClient.SceneAgent.AbsolutePosition; ILandObject land = s.LandChannel.GetLandObject(pos.X, pos.Y); - ScenePresence p = FindPresence(remoteClient.AgentId); - + UUID creatorId = remoteClient.AgentId; + ScenePresence p = FindPresence(creatorId); + string serverURI = string.Empty; GetUserProfileServerURI(remoteClient.AgentId, out serverURI); - if (land == null) + OSDMap parameters = new OSDMap {{"creatorId", OSD.FromUUID(creatorId)}}; + OSD Params = (OSD)parameters; + if (!rpc.JsonRpcRequest(ref Params, "avatarclassifiedsrequest", serverURI, UUID.Random().ToString())) { - ad.ParcelName = string.Empty; + remoteClient.SendAgentAlertMessage("Error fetching classifieds", false); + return; } - else + parameters = (OSDMap)Params; + OSDArray list = (OSDArray)parameters["result"]; + bool exists = list.Cast().Where(map => map.ContainsKey("classifieduuid")) + .Any(map => map["classifieduuid"].AsUUID().Equals(queryclassifiedID)); + + if (!exists) { - ad.ParcelName = land.LandData.Name; + IMoneyModule money = s.RequestModuleInterface(); + if (money != null) + { + if (!money.AmountCovered(remoteClient.AgentId, queryclassifiedPrice)) + { + remoteClient.SendAgentAlertMessage("You do not have enough money to create this classified.", false); + return; + } + money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, MoneyTransactionType.ClassifiedCharge); + } } + UserClassifiedAdd ad = new UserClassifiedAdd(); + + ad.ParcelName = land == null ? string.Empty : land.LandData.Name; ad.CreatorId = remoteClient.AgentId; ad.ClassifiedId = queryclassifiedID; ad.Category = Convert.ToInt32(queryCategory); @@ -507,9 +515,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles if(!rpc.JsonRpcRequest(ref Ad, "classified_update", serverURI, UUID.Random().ToString())) { - remoteClient.SendAgentAlertMessage( - "Error updating classified", false); - return; + remoteClient.SendAgentAlertMessage("Error updating classified", false); } } -- cgit v1.1