mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 09:16:28 +08:00
mantis 9188: add HG assets scan and fetch when droping a item on a prim
This commit is contained in:
@@ -96,8 +96,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", true);
|
||||
m_CheckSeparateAssets = thisModuleConfig.GetBoolean("CheckSeparateAssets", false);
|
||||
m_LocalAssetsURL = thisModuleConfig.GetString("RegionHGAssetServerURI", string.Empty);
|
||||
m_LocalAssetsURL = m_LocalAssetsURL.Trim(new char[] { '/' });
|
||||
|
||||
m_LocalAssetsURL = m_LocalAssetsURL.Trim('/');
|
||||
}
|
||||
else
|
||||
m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found");
|
||||
@@ -318,6 +317,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
if (item is null || item.AssetID.IsZero())
|
||||
return null;
|
||||
|
||||
if(item.AssetType == (int)AssetType.Link || item.AssetType == (int)AssetType.LinkFolder)
|
||||
{
|
||||
m_log.Error("[HGScene]: request to rez a asset inventory link");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (attachment && (item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) != 0)
|
||||
{
|
||||
if (remoteClient is not null && remoteClient.IsActive)
|
||||
@@ -325,8 +330,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
return null;
|
||||
}
|
||||
|
||||
string userAssetServer;
|
||||
if (IsForeignUser(remoteClient.AgentId, out userAssetServer))
|
||||
if (IsForeignUser(remoteClient.AgentId, out string userAssetServer))
|
||||
{
|
||||
m_assMapper.Get(item.AssetID, remoteClient.AgentId, userAssetServer);
|
||||
}
|
||||
@@ -339,6 +343,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
|
||||
}
|
||||
|
||||
public override void FetchRemoteHGItemAssets(UUID OwnerID, InventoryItemBase item)
|
||||
{
|
||||
if(item is null || item.AssetID.IsZero())
|
||||
return;
|
||||
if(item.AssetType == (int)AssetType.Link || item.AssetType == (int)AssetType.LinkFolder)
|
||||
{
|
||||
m_log.Error("[HGScene]: request to fetch a asset inventory link");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsForeignUser(OwnerID, out string userAssetServer))
|
||||
m_assMapper.Get(item.AssetID, OwnerID, userAssetServer);
|
||||
}
|
||||
|
||||
public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
|
||||
{
|
||||
string senderAssetServer;
|
||||
@@ -355,7 +373,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
// If both users have the same asset server, no need to transfer the asset
|
||||
if (senderAssetServer.Equals(receiverAssetServer))
|
||||
{
|
||||
m_log.DebugFormat("[HGScene]: Asset transfer between foreign users, but they have the same server. No transfer.");
|
||||
m_log.Debug("[HGScene]: Asset transfer between foreign users, but they have the same server. No transfer.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -376,19 +394,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
{
|
||||
if (!UserManagementModule.IsLocalGridUser(userID))
|
||||
{ // foreign
|
||||
if (m_Scene.TryGetScenePresence(userID, out ScenePresence sp))
|
||||
{
|
||||
AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
|
||||
if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
|
||||
{
|
||||
assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString();
|
||||
assetServerURL = assetServerURL.Trim(new char[] { '/' });
|
||||
}
|
||||
}
|
||||
else
|
||||
AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(userID);
|
||||
if (aCircuit != null && aCircuit.ServiceURLs != null &&
|
||||
aCircuit.ServiceURLs.TryGetValue("AssetServerURI", out object oassetServerURL) &&
|
||||
oassetServerURL is string stmp)
|
||||
assetServerURL = stmp.Trim('/');
|
||||
|
||||
if(assetServerURL.Length == 0)
|
||||
{
|
||||
assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI");
|
||||
assetServerURL = assetServerURL.Trim(new char[] { '/' });
|
||||
assetServerURL = assetServerURL.Trim('/');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -397,7 +412,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
{
|
||||
if (IsLocalInventoryAssetsUser(userID, out assetServerURL))
|
||||
{
|
||||
m_log.DebugFormat("[HGScene]: user {0} has local assets {1}", userID, assetServerURL);
|
||||
m_log.Debug($"[HGScene]: user {userID} has local assets {assetServerURL}");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -416,10 +431,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
if (assetsURL.Length == 0)
|
||||
{
|
||||
AgentCircuitData agent = m_Scene.AuthenticateHandler.GetAgentCircuitData(uuid);
|
||||
if (agent != null)
|
||||
if (agent != null && agent.ServiceURLs != null &&
|
||||
agent.ServiceURLs.TryGetValue("AssetServerURI", out object oassetServerURL) &&
|
||||
oassetServerURL is string stmp)
|
||||
{
|
||||
assetsURL = agent.ServiceURLs["AssetServerURI"].ToString();
|
||||
assetsURL = assetsURL.Trim(new char[] { '/' });
|
||||
assetsURL = stmp.Trim('/');
|
||||
}
|
||||
}
|
||||
return m_LocalAssetsURL.Equals(assetsURL);
|
||||
|
||||
@@ -1131,6 +1131,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
return group;
|
||||
}
|
||||
|
||||
public virtual void FetchRemoteHGItemAssets(UUID OwnerID, InventoryItemBase item)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Do pre-rez processing when the object comes from an item.
|
||||
/// </summary>
|
||||
|
||||
@@ -127,6 +127,8 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
|
||||
bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment);
|
||||
|
||||
void FetchRemoteHGItemAssets(UUID OwnerID, InventoryItemBase item);
|
||||
|
||||
void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1768,9 +1768,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
UUID itemID = itemInfo.ItemID;
|
||||
if (itemID.IsZero())
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIM INVENTORY]: UpdateTaskInventory called with item ID Zero on update for {1}!",
|
||||
remoteClient.Name);
|
||||
m_log.Error($"[PRIM INVENTORY]: UpdateTaskInventory called with item ID Zero on update for {remoteClient.Name}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1778,11 +1776,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
SceneObjectPart part = GetSceneObjectPart(primLocalID);
|
||||
if(part is null)
|
||||
{
|
||||
m_log.WarnFormat(
|
||||
"[PRIM INVENTORY]: " +
|
||||
"Update with item {0} requested of prim {1} for {2} but this prim does not exist",
|
||||
itemID, primLocalID, remoteClient.Name);
|
||||
return;
|
||||
m_log.Warn(
|
||||
$"[PRIM INVENTORY]: Update prim {primLocalID} with item {itemID} by {remoteClient.Name} but prim not found");
|
||||
return;
|
||||
}
|
||||
|
||||
TaskInventoryItem currentItem = part.Inventory.GetInventoryItem(itemID);
|
||||
@@ -1797,29 +1793,27 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
if(item is null)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIM INVENTORY]: Could not find inventory item {0} to update for {1}!",
|
||||
itemID, remoteClient.Name);
|
||||
m_log.Error(
|
||||
$"[PRIM INVENTORY]: Could not find inventory item {itemID} to update for {remoteClient.Name}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Permissions.CanDropInObjectInv(item, remoteClient, part))
|
||||
return;
|
||||
|
||||
UUID copyID = UUID.Random();
|
||||
bool modrights = Permissions.CanEditObject(part.ParentGroup, remoteClient);
|
||||
part.ParentGroup.AddInventoryItem(remoteClient.AgentId, primLocalID, item, copyID, modrights);
|
||||
m_log.InfoFormat(
|
||||
"[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
|
||||
item.Name, primLocalID, remoteClient.Name);
|
||||
part.ParentGroup.AddInventoryItem(remoteClient.AgentId, primLocalID, item, UUID.Random(), modrights);
|
||||
m_log.Info(
|
||||
$"[PRIM INVENTORY]: Update prim {primLocalID} with item {item.Name} requested by {remoteClient.Name}");
|
||||
|
||||
IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
|
||||
invAccess?.FetchRemoteHGItemAssets(remoteClient.AgentId, item);
|
||||
|
||||
part.SendPropertiesToClient(remoteClient);
|
||||
if (!Permissions.BypassPermissions())
|
||||
{
|
||||
if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
|
||||
{
|
||||
List<UUID> uuids = new() { itemID };
|
||||
RemoveInventoryItem(remoteClient, uuids);
|
||||
}
|
||||
RemoveInventoryItem(remoteClient, [itemID]);
|
||||
}
|
||||
}
|
||||
else // Updating existing item with new perms etc
|
||||
|
||||
Reference in New Issue
Block a user