From 0517e3d439e6888a739de90286267ee2f946c8df Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 20 Aug 2016 22:44:00 +0100 Subject: [PATCH] Mantis #8000, don't charge for updating classifieds. Thanks, Cinder! Signed-off-by: Melanie Thielker --- .../Avatar/UserProfiles/UserProfileModule.cs | 56 ++++++++++--------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 145f3dbc7b..61835f9d71 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(); + Vector3 pos = remoteClient.SceneAgent.AbsolutePosition; + ILandObject land = s.LandChannel.GetLandObject(pos.X, pos.Y); + UUID creatorId = remoteClient.AgentId; + ScenePresence p = FindPresence(creatorId); - if (money != null) + string serverURI = string.Empty; + GetUserProfileServerURI(remoteClient.AgentId, out serverURI); + + OSDMap parameters = new OSDMap {{"creatorId", OSD.FromUUID(creatorId)}}; + OSD Params = (OSD)parameters; + if (!rpc.JsonRpcRequest(ref Params, "avatarclassifiedsrequest", serverURI, UUID.Random().ToString())) { - if (!money.AmountCovered(remoteClient.AgentId, queryclassifiedPrice)) + remoteClient.SendAgentAlertMessage("Error fetching classifieds", false); + return; + } + 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) + { + IMoneyModule money = s.RequestModuleInterface(); + if (money != null) { - remoteClient.SendAgentAlertMessage("You do not have enough money to create requested classified.", false); - return; + 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); } - 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); - - string serverURI = string.Empty; - GetUserProfileServerURI(remoteClient.AgentId, out serverURI); - - if (land == null) - { - ad.ParcelName = string.Empty; - } - else - { - ad.ParcelName = land.LandData.Name; - } - + 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); } }