Closed huan closed 1 year ago
Why not use protobuf
to define FileBox
?
FileBox
must be implemented in multi-language,so I suggest that we should define FileBox
in proto file.
wechaty:1.20.2
contact?.say(fileBox)
still call MessageSendFileStream
!
@huan
Thanks for the suggestion and question, @zpaimon !
For your first question about defiling a FileBox
in protobuf
; You can refer to the below links first to get some background:
To brief short:
file_box
The reason we use the above design is that when we are using gRPC stream API, it's hard to pass parameters. (refer to https://github.com/wechaty/grpc/issues/96 )
For your second question, please learn more about our new UUID FileBox design from this PR:
And the current code base of the wechaty-puppet-service will do that:
You can read the source code about the above logic, and please feel free to let me know if you have more questions.
If the deprecated gRPC call does not work, use the new design.
How to force wechaty to use new gRPC design?
If I don't implement MessageStream method,it will throw Method wechaty.Puppet/MessageSendFileStream is unimplemented
.
That's a good question.
We can think about the below two solutions:
try {} catch () {}
the unimplemented
error, which can make it to use the new way;Method wechaty.Puppet/MessageSendFileStream
and always throw an error? (We can remove the deprecated compatible code after Dec 31, 2022)Thank you very much! I make it work under my wework protocol project(code:marbas
).
That's awesome; great to know that!
Do you have any plan for publishing the marbas
to the community? I'm looking forward to that.
I'm working hard at marbas
.I will push alpha version in the recent days.
@huan who can help me to test marbas
?
My suggestion is to post an alpha testing announcement in our blog post (or GitHub issue), then tell our developers in the WeChat contributors & developers' home group to let them contact you with the alpha testing (distribute marbas TOKEN to them)
Feel free to let me know if you need any help from my side.
The download does not respond when the download exceeds 90K
We will remove three gRPC interfaces after Dec 31, 2022:
MessageFileStreamMessageImageStreamMessageSendFileStreamhttps://github.com/wechaty/grpc/blob/68092819e85e535361dffcc5b79f3cdce3372e8f/proto/wechaty/puppet.proto#L66-L72
The removal of them is because we need to simplify the design and make it more robust and scalable with our infrastructure.
The New Way
gRPC
We are using the below four new abstracted interfaces
UploadRequest
,UploadResponse
,DownloadRequest
, andDownloadResponse
in the future, for simplification.https://github.com/wechaty/grpc/blob/9dfa195c6f0ec36741a784392f1486bb4d2bd3c6/proto/wechaty/puppet/download-upload.proto#L7-L19
gRPC Related Code
DownloadRequest
A
DownloadRequest
can convert aUUID
toStream
:https://github.com/wechaty/puppet-service/blob/ef72d99747c037cad48e532c0797737adffc0c2b/src/file-box-helper/uuidify-file-box-grpc.ts#L27-L35
UploadRequest
A
UploadRequest
can convert aStream
toUUID
:https://github.com/wechaty/puppet-service/blob/ef72d99747c037cad48e532c0797737adffc0c2b/src/file-box-helper/uuidify-file-box-grpc.ts#L44-L59
Using
UUID
type ofFileBox
Url
,QRCode
,Uuid
, etc., then it can be serialized byfileBox.toString()
Stream
,Buffer
,File
, etc, then it needs to be converted to typeUuid
before serialized byfileBox.toString()
Check if the FileBox should be converted to UUID
https://github.com/wechaty/puppet-service/blob/ef72d99747c037cad48e532c0797737adffc0c2b/src/server/puppet-implementation.ts#L83-L93
Convert a FileBox from Stream (etc.) types to UUID type
https://github.com/wechaty/puppet-service/blob/ef72d99747c037cad48e532c0797737adffc0c2b/src/file-box-helper/normalize-filebox.ts#L72-L79
CC @zpaimon