diff options
author | UbitUmarov | 2016-12-22 07:52:50 +0000 |
---|---|---|
committer | UbitUmarov | 2016-12-22 07:52:50 +0000 |
commit | 84c3a96399f5233a075100739c270d0202aaaee8 (patch) | |
tree | 3b185cc43689c1242400703467e72e8dfd771b3f /OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs | |
parent | UserProfileModule we can't use parcels globalID because we do not have a glob... (diff) | |
download | opensim-SC_OLD-84c3a96399f5233a075100739c270d0202aaaee8.zip opensim-SC_OLD-84c3a96399f5233a075100739c270d0202aaaee8.tar.gz opensim-SC_OLD-84c3a96399f5233a075100739c270d0202aaaee8.tar.bz2 opensim-SC_OLD-84c3a96399f5233a075100739c270d0202aaaee8.tar.xz |
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
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 7a874e2..1ea1306 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs | |||
@@ -570,29 +570,29 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
570 | uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos, byte queryclassifiedFlags, | 570 | uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos, byte queryclassifiedFlags, |
571 | int queryclassifiedPrice, IClientAPI remoteClient) | 571 | int queryclassifiedPrice, IClientAPI remoteClient) |
572 | { | 572 | { |
573 | |||
574 | Scene s = (Scene)remoteClient.Scene; | 573 | Scene s = (Scene)remoteClient.Scene; |
575 | Vector3 pos = remoteClient.SceneAgent.AbsolutePosition; | 574 | Vector3 pos = remoteClient.SceneAgent.AbsolutePosition; |
576 | ILandObject land = s.LandChannel.GetLandObject(pos.X, pos.Y); | 575 | ILandObject land = s.LandChannel.GetLandObject(pos.X, pos.Y); |
577 | UUID creatorId = remoteClient.AgentId; | 576 | UUID creatorId = remoteClient.AgentId; |
578 | ScenePresence p = FindPresence(creatorId); | 577 | ScenePresence p = FindPresence(creatorId); |
579 | 578 | ||
579 | UserProfileCacheEntry uce = null; | ||
580 | lock(m_profilesCache) | ||
581 | m_profilesCache.TryGetValue(remoteClient.AgentId, out uce); | ||
582 | |||
580 | string serverURI = string.Empty; | 583 | string serverURI = string.Empty; |
581 | GetUserProfileServerURI(remoteClient.AgentId, out serverURI); | 584 | bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI); |
582 | if(string.IsNullOrWhiteSpace(serverURI)) | 585 | if(string.IsNullOrWhiteSpace(serverURI)) |
583 | { | 586 | { |
584 | return; | 587 | return; |
585 | } | 588 | } |
586 | 589 | ||
587 | // just flush cache for now | 590 | if(foreign) |
588 | UserProfileCacheEntry uce = null; | ||
589 | lock(m_profilesCache) | ||
590 | { | 591 | { |
591 | if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null) | 592 | remoteClient.SendAgentAlertMessage("Please change classifieds on your home grid", true); |
592 | { | 593 | if(uce != null && uce.classifiedsLists != null) |
593 | uce.classifieds = null; | 594 | remoteClient.SendAvatarClassifiedReply(remoteClient.AgentId, uce.classifiedsLists); |
594 | uce.classifiedsLists = null; | 595 | return; |
595 | } | ||
596 | } | 596 | } |
597 | 597 | ||
598 | OSDMap parameters = new OSDMap {{"creatorId", OSD.FromUUID(creatorId)}}; | 598 | OSDMap parameters = new OSDMap {{"creatorId", OSD.FromUUID(creatorId)}}; |
@@ -607,17 +607,20 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
607 | bool exists = list.Cast<OSDMap>().Where(map => map.ContainsKey("classifieduuid")) | 607 | bool exists = list.Cast<OSDMap>().Where(map => map.ContainsKey("classifieduuid")) |
608 | .Any(map => map["classifieduuid"].AsUUID().Equals(queryclassifiedID)); | 608 | .Any(map => map["classifieduuid"].AsUUID().Equals(queryclassifiedID)); |
609 | 609 | ||
610 | IMoneyModule money = null; | ||
610 | if (!exists) | 611 | if (!exists) |
611 | { | 612 | { |
612 | IMoneyModule money = s.RequestModuleInterface<IMoneyModule>(); | 613 | money = s.RequestModuleInterface<IMoneyModule>(); |
613 | if (money != null) | 614 | if (money != null) |
614 | { | 615 | { |
615 | if (!money.AmountCovered(remoteClient.AgentId, queryclassifiedPrice)) | 616 | if (!money.AmountCovered(remoteClient.AgentId, queryclassifiedPrice)) |
616 | { | 617 | { |
617 | remoteClient.SendAgentAlertMessage("You do not have enough money to create this classified.", false); | 618 | remoteClient.SendAgentAlertMessage("You do not have enough money to create this classified.", false); |
619 | if(uce != null && uce.classifiedsLists != null) | ||
620 | remoteClient.SendAvatarClassifiedReply(remoteClient.AgentId, uce.classifiedsLists); | ||
618 | return; | 621 | return; |
619 | } | 622 | } |
620 | money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, MoneyTransactionType.ClassifiedCharge); | 623 | // money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, MoneyTransactionType.ClassifiedCharge); |
621 | } | 624 | } |
622 | } | 625 | } |
623 | 626 | ||
@@ -644,7 +647,25 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
644 | if(!rpc.JsonRpcRequest(ref Ad, "classified_update", serverURI, UUID.Random().ToString())) | 647 | if(!rpc.JsonRpcRequest(ref Ad, "classified_update", serverURI, UUID.Random().ToString())) |
645 | { | 648 | { |
646 | remoteClient.SendAgentAlertMessage("Error updating classified", false); | 649 | remoteClient.SendAgentAlertMessage("Error updating classified", false); |
650 | if(uce != null && uce.classifiedsLists != null) | ||
651 | remoteClient.SendAvatarClassifiedReply(remoteClient.AgentId, uce.classifiedsLists); | ||
652 | return; | ||
647 | } | 653 | } |
654 | |||
655 | // only charge if it worked | ||
656 | if (money != null) | ||
657 | money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, MoneyTransactionType.ClassifiedCharge); | ||
658 | |||
659 | // just flush cache for now | ||
660 | lock(m_profilesCache) | ||
661 | { | ||
662 | if(uce != null) | ||
663 | { | ||
664 | uce.classifieds = null; | ||
665 | uce.classifiedsLists = null; | ||
666 | } | ||
667 | } | ||
668 | |||
648 | } | 669 | } |
649 | 670 | ||
650 | /// <summary> | 671 | /// <summary> |
@@ -670,10 +691,15 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
670 | } | 691 | } |
671 | 692 | ||
672 | string serverURI = string.Empty; | 693 | string serverURI = string.Empty; |
673 | GetUserProfileServerURI(remoteClient.AgentId, out serverURI); | 694 | bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI); |
674 | if(string.IsNullOrWhiteSpace(serverURI)) | 695 | if(string.IsNullOrWhiteSpace(serverURI)) |
675 | return; | 696 | return; |
676 | 697 | ||
698 | if(foreign) | ||
699 | { | ||
700 | remoteClient.SendAgentAlertMessage("Please change classifieds on your home grid", true); | ||
701 | return; | ||
702 | } | ||
677 | UUID classifiedId; | 703 | UUID classifiedId; |
678 | if(!UUID.TryParse(queryClassifiedID.ToString(), out classifiedId)) | 704 | if(!UUID.TryParse(queryClassifiedID.ToString(), out classifiedId)) |
679 | return; | 705 | return; |