Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets.RequestInventoryAsset is broken for reading notecards [SL] #86

Open
Madpeterz opened this issue Jun 25, 2023 · 1 comment
Open

Comments

@Madpeterz
Copy link
Contributor

Madpeterz commented Jun 25, 2023

libremetaverse
Known broken versions:

  • 2.0.10.575
  • 2.0.6.545
  • 2.0.3.521

works on version:

  • 1.9.17.425

Radegast

  • Known broken in version: 2.41
  • works on version: 2.30

example code

    public void NotecardToMem(string notecardUUID)
    {
        if (UUID.TryParse(notecardUUID, out UUID inventoryUUID) == false)
        {
             client.Self.Chat("Unable to read notecard UUID", 0, ChatType.Normal);
        }
        InventoryItem A = client.Inventory.FetchItem(inventoryUUID, client.Self.AgentID, 2000);
        if (A == null)
        {
            client.Self.Chat("Unable to find notecard with UUID", 0, ChatType.Normal);
        }
        if(A.InventoryType != InventoryType.Notecard)
        {
            client.Self.Chat("Unable to find notecard with UUID", 0, ChatType.Normal);
        }
        var transferID = UUID.Random();
        client.Assets.RequestInventoryAsset(
            A,
            true,
            transferID,
            (AssetDownload transfer, Asset asset) =>
            {
                if (transfer.Success && transfer.ID == transferID)
                {
                    AssetNotecard n = (AssetNotecard)asset;
                    n.Decode();
                    AssetNotecard recievedNotecard = n;

                    string text = string.Empty;

                    for (int i = 0; i < n.BodyText.Length; i++)
                    {
                        char c = n.BodyText[i];

                        // Special marker for embedded things.
                        if ((int)c == 0xdbc0)
                        {
                            int index = (int)n.BodyText[++i] - 0xdc00;
                            InventoryItem e = n.EmbeddedItems[index];
                            text += " (embedded) ";
                        }
                        else
                        {
                            text += c;
                        }
                    }
                    client.Self.Chat(text, 0, ChatType.Normal);

                }
                else
                {
                    client.Self.Chat("Transfer failed", 0, ChatType.Normal);
                }
            }
        );
        client.Self.Chat("working on it", 0, ChatType.Normal);
    }

expected output:
working on it
"Hello world"

current results:
Failed to fetch asset : BadRequest Bad Request

notes:
if you request a asset that was loaded with the older version and then update to current
and redo the request it works as expected.

@Madpeterz
Copy link
Contributor Author

worked around by: #87

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant