How to extract uuid filebox
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?
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.
I'm using [email protected] and [email protected] on both sides
If you are sure this bug exists, then adding a unit test that can fail the CI would be appreciated.
#210
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')
})
It should be fixed by your PR; please test it and close this issue if there are no more problems with the UUID FileBox.