mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 02:36:00 +08:00
Patch #9171
Disallow bulk uploads if money module is present and upload cost is set and the user hasn't got sufficient funds.
This commit is contained in:
@@ -261,6 +261,23 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||
public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type,
|
||||
byte[] data, bool storeLocal, bool tempFile)
|
||||
{
|
||||
if ((AssetType)type == AssetType.Texture ||
|
||||
(AssetType)type == AssetType.Sound ||
|
||||
(AssetType)type == AssetType.TextureTGA ||
|
||||
(AssetType)type == AssetType.Animation)
|
||||
{
|
||||
Scene scene = (Scene)remoteClient.Scene;
|
||||
IMoneyModule mm = scene.RequestModuleInterface<IMoneyModule>();
|
||||
if (mm != null)
|
||||
{
|
||||
if (!mm.UploadCovered(remoteClient))
|
||||
{
|
||||
remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Console.WriteLine("asset upload of " + assetID);
|
||||
AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
|
||||
|
||||
@@ -288,4 +305,4 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||
transactions.HandleXfer(xferID, packetID, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,11 +266,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
|
||||
scene.SetObjectCapacity(ObjectCapacity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// New Client Event Handler
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
private void OnNewClient(IClientAPI client)
|
||||
private void GetClientFunds(IClientAPI client)
|
||||
{
|
||||
// Here we check if we're in grid mode
|
||||
// I imagine that the 'check balance'
|
||||
@@ -343,6 +339,16 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
|
||||
CheckExistAndRefreshFunds(client.AgentId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// New Client Event Handler
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
private void OnNewClient(IClientAPI client)
|
||||
{
|
||||
GetClientFunds(client);
|
||||
|
||||
// Subscribe to Money messages
|
||||
client.OnEconomyDataRequest += EconomyDataRequestHandler;
|
||||
client.OnMoneyBalanceRequest += SendMoneyBalance;
|
||||
@@ -1525,6 +1531,27 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
|
||||
DeadAvatar.Scene.TeleportClientHome(DeadAvatar.UUID, DeadAvatar.ControllingClient);
|
||||
}
|
||||
|
||||
public int GetBalance(IClientAPI client)
|
||||
{
|
||||
GetClientFunds(client);
|
||||
|
||||
lock(m_KnownClientFunds)
|
||||
{
|
||||
if (!m_KnownClientFunds.ContainsKey(client.AgentId))
|
||||
return 0;
|
||||
|
||||
return m_KnownClientFunds[client.AgentId];
|
||||
}
|
||||
}
|
||||
|
||||
public bool UploadCovered(IClientAPI client)
|
||||
{
|
||||
if (GetBalance(client) < PriceUpload)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user