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

How to extract uuid filebox #206

Open
hcfw007 opened this issue May 10, 2022 · 6 comments
Open

How to extract uuid filebox #206

hcfw007 opened this issue May 10, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@hcfw007
Copy link
Member

hcfw007 commented May 10, 2022

I tried to download message image with the following test code:

  bot.on('message', async message => {
    if (message.type() === types.Message.Image) {
      const image = message.toImage()
      const file = await image.hd()
      await file.toFile()
    }
})

and got this error message:
Error: need to call FileBox.setUuidLoader() to set UUID loader first.

I tried to get how to set loader from puppet-service and file-box source code, but failed. Could please provide an example when receiving a uuid filebox from wechaty-puppet-service?

@huan
Copy link
Member

huan commented May 10, 2022

What's the version of your Wechaty & Wechaty Puppet Service Server?

By design, the UUID FileBox should be worked out of the box without any additional configuration.

If you can make sure the latest version of the Wechaty and the Server (important: service server must be the latest version for the UUID FileBox supports), please feel free to provide a reproducible unit test then we can try to fix it.

@huan huan added the question Further information is requested label May 10, 2022
@hcfw007
Copy link
Member Author

hcfw007 commented May 10, 2022

I'm using [email protected] and [email protected] on both sides

@huan
Copy link
Member

huan commented May 10, 2022

If you are sure this bug exists, then adding a unit test that can fail the CI would be appreciated.

@hcfw007
Copy link
Member Author

hcfw007 commented May 12, 2022

#210

@huan
Copy link
Member

huan commented May 14, 2022

Thanks for your unit test; it's very helpful.

With your code, I am able to reproduce the bug, and it's related to the FileBox.fromJSON() method.

Here's the minimum reproducible code for FileBox:

test('message file test', async t => {
  const JSON_TEXT = '{"metadata":{},"name":"smoke-testing.ts","size":735,"type":7,"uuid":"82f461b9-e654-422d-aade-222d05cb02ad","boxType":7}'
  const FileBoxUuid = uuidifyFileBoxGrpc(() => ({} as any))
  const fileBoxUuid = FileBoxUuid.fromJSON(JSON_TEXT)
  t.equal(instanceToClass(fileBoxUuid, FileBox), FileBoxUuid, 'should get back FileBoxUuid class')
})

@huan huan added bug Something isn't working and removed question Further information is requested labels May 14, 2022
@huan
Copy link
Member

huan commented May 14, 2022

It should be fixed by your PR; please test it and close this issue if there are no more problems with the UUID FileBox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants