UserProfileModule refuse changes to classifieds outside home grid ( viewers may show a delete until profile is open again). Charge money only on classified creation sucess
parent
5571c499ba
commit
84c3a96399
|
@ -570,29 +570,29 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
|
||||||
uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos, byte queryclassifiedFlags,
|
uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos, byte queryclassifiedFlags,
|
||||||
int queryclassifiedPrice, IClientAPI remoteClient)
|
int queryclassifiedPrice, IClientAPI remoteClient)
|
||||||
{
|
{
|
||||||
|
|
||||||
Scene s = (Scene)remoteClient.Scene;
|
Scene s = (Scene)remoteClient.Scene;
|
||||||
Vector3 pos = remoteClient.SceneAgent.AbsolutePosition;
|
Vector3 pos = remoteClient.SceneAgent.AbsolutePosition;
|
||||||
ILandObject land = s.LandChannel.GetLandObject(pos.X, pos.Y);
|
ILandObject land = s.LandChannel.GetLandObject(pos.X, pos.Y);
|
||||||
UUID creatorId = remoteClient.AgentId;
|
UUID creatorId = remoteClient.AgentId;
|
||||||
ScenePresence p = FindPresence(creatorId);
|
ScenePresence p = FindPresence(creatorId);
|
||||||
|
|
||||||
|
UserProfileCacheEntry uce = null;
|
||||||
|
lock(m_profilesCache)
|
||||||
|
m_profilesCache.TryGetValue(remoteClient.AgentId, out uce);
|
||||||
|
|
||||||
string serverURI = string.Empty;
|
string serverURI = string.Empty;
|
||||||
GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
|
bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
|
||||||
if(string.IsNullOrWhiteSpace(serverURI))
|
if(string.IsNullOrWhiteSpace(serverURI))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// just flush cache for now
|
if(foreign)
|
||||||
UserProfileCacheEntry uce = null;
|
|
||||||
lock(m_profilesCache)
|
|
||||||
{
|
{
|
||||||
if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null)
|
remoteClient.SendAgentAlertMessage("Please change classifieds on your home grid", true);
|
||||||
{
|
if(uce != null && uce.classifiedsLists != null)
|
||||||
uce.classifieds = null;
|
remoteClient.SendAvatarClassifiedReply(remoteClient.AgentId, uce.classifiedsLists);
|
||||||
uce.classifiedsLists = null;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OSDMap parameters = new OSDMap {{"creatorId", OSD.FromUUID(creatorId)}};
|
OSDMap parameters = new OSDMap {{"creatorId", OSD.FromUUID(creatorId)}};
|
||||||
|
@ -607,17 +607,20 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
|
||||||
bool exists = list.Cast<OSDMap>().Where(map => map.ContainsKey("classifieduuid"))
|
bool exists = list.Cast<OSDMap>().Where(map => map.ContainsKey("classifieduuid"))
|
||||||
.Any(map => map["classifieduuid"].AsUUID().Equals(queryclassifiedID));
|
.Any(map => map["classifieduuid"].AsUUID().Equals(queryclassifiedID));
|
||||||
|
|
||||||
|
IMoneyModule money = null;
|
||||||
if (!exists)
|
if (!exists)
|
||||||
{
|
{
|
||||||
IMoneyModule money = s.RequestModuleInterface<IMoneyModule>();
|
money = s.RequestModuleInterface<IMoneyModule>();
|
||||||
if (money != null)
|
if (money != null)
|
||||||
{
|
{
|
||||||
if (!money.AmountCovered(remoteClient.AgentId, queryclassifiedPrice))
|
if (!money.AmountCovered(remoteClient.AgentId, queryclassifiedPrice))
|
||||||
{
|
{
|
||||||
remoteClient.SendAgentAlertMessage("You do not have enough money to create this classified.", false);
|
remoteClient.SendAgentAlertMessage("You do not have enough money to create this classified.", false);
|
||||||
|
if(uce != null && uce.classifiedsLists != null)
|
||||||
|
remoteClient.SendAvatarClassifiedReply(remoteClient.AgentId, uce.classifiedsLists);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, MoneyTransactionType.ClassifiedCharge);
|
// money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, MoneyTransactionType.ClassifiedCharge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -644,7 +647,25 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
|
||||||
if(!rpc.JsonRpcRequest(ref Ad, "classified_update", serverURI, UUID.Random().ToString()))
|
if(!rpc.JsonRpcRequest(ref Ad, "classified_update", serverURI, UUID.Random().ToString()))
|
||||||
{
|
{
|
||||||
remoteClient.SendAgentAlertMessage("Error updating classified", false);
|
remoteClient.SendAgentAlertMessage("Error updating classified", false);
|
||||||
|
if(uce != null && uce.classifiedsLists != null)
|
||||||
|
remoteClient.SendAvatarClassifiedReply(remoteClient.AgentId, uce.classifiedsLists);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only charge if it worked
|
||||||
|
if (money != null)
|
||||||
|
money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, MoneyTransactionType.ClassifiedCharge);
|
||||||
|
|
||||||
|
// just flush cache for now
|
||||||
|
lock(m_profilesCache)
|
||||||
|
{
|
||||||
|
if(uce != null)
|
||||||
|
{
|
||||||
|
uce.classifieds = null;
|
||||||
|
uce.classifiedsLists = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -670,10 +691,15 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
|
||||||
}
|
}
|
||||||
|
|
||||||
string serverURI = string.Empty;
|
string serverURI = string.Empty;
|
||||||
GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
|
bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
|
||||||
if(string.IsNullOrWhiteSpace(serverURI))
|
if(string.IsNullOrWhiteSpace(serverURI))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(foreign)
|
||||||
|
{
|
||||||
|
remoteClient.SendAgentAlertMessage("Please change classifieds on your home grid", true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
UUID classifiedId;
|
UUID classifiedId;
|
||||||
if(!UUID.TryParse(queryClassifiedID.ToString(), out classifiedId))
|
if(!UUID.TryParse(queryClassifiedID.ToString(), out classifiedId))
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue