From a326dc68abf476260f2970bf20e6cd19ace5d1da Mon Sep 17 00:00:00 2001 From: windmemory Date: Thu, 15 Oct 2020 00:44:33 +0800 Subject: [PATCH 1/7] add file stream and image stream rpc call --- proto/wechaty/puppet.proto | 2 ++ proto/wechaty/puppet/message.proto | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/proto/wechaty/puppet.proto b/proto/wechaty/puppet.proto index 1b6878b1..a9305c2e 100644 --- a/proto/wechaty/puppet.proto +++ b/proto/wechaty/puppet.proto @@ -93,7 +93,9 @@ service Puppet { rpc MessageContact (puppet.MessageContactRequest) returns (puppet.MessageContactResponse) {} rpc MessageFile (puppet.MessageFileRequest) returns (puppet.MessageFileResponse) {} + rpc MessageFileStream (puppet.MessageFileStreamRequest) returns (stream puppet.MessageFileStreamResponse) {} rpc MessageImage (puppet.MessageImageRequest) returns (puppet.MessageImageResponse) {} + rpc MessageImageStream (puppet.MessageImageStreamRequest) returns (stream puppet.MessageImageStreamResponse) {} rpc MessageMiniProgram (puppet.MessageMiniProgramRequest) returns (puppet.MessageMiniProgramResponse) {} rpc MessageUrl (puppet.MessageUrlRequest) returns (puppet.MessageUrlResponse) {} diff --git a/proto/wechaty/puppet/message.proto b/proto/wechaty/puppet/message.proto index af398e95..a7cdc9c9 100644 --- a/proto/wechaty/puppet/message.proto +++ b/proto/wechaty/puppet/message.proto @@ -56,6 +56,13 @@ message MessageImageResponse { string filebox = 1; } +message MessageImageStreamRequest { + string id = 1; +} +message MessageImageStreamResponse { + bytes data = 1; +} + message MessageContactRequest { string id = 1; } @@ -70,6 +77,13 @@ message MessageFileResponse { string filebox = 1; } +message MessageFileStreamRequest { + string id = 1; +} +message MessageFileStreamResponse { + bytes data = 1; +} + message MessageMiniProgramRequest { string id = 1; } From 3117aa2b1b28d1f0d8ef41d4b673ba35eb7930a7 Mon Sep 17 00:00:00 2001 From: windmemory Date: Thu, 15 Oct 2020 00:49:17 +0800 Subject: [PATCH 2/7] fix test --- tests/puppet-server-impl.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/puppet-server-impl.ts b/tests/puppet-server-impl.ts index 26bdd38e..34ac3fd3 100644 --- a/tests/puppet-server-impl.ts +++ b/tests/puppet-server-impl.ts @@ -133,12 +133,22 @@ export const puppetServerImpl: IPuppetServer = { throw new Error('not implemented.') }, + messageFileStream: (call) => { + void call + throw new Error('not implemented.') + }, + messageImage: (call, callback) => { void call void callback throw new Error('not implemented.') }, + messageImageStream: (call) => { + void call + throw new Error('not implemented.') + }, + messageMiniProgram: (call, callback) => { void call void callback From 4c04b4e2f94734ac2d09ffd7326945864ac03de3 Mon Sep 17 00:00:00 2001 From: windmemory Date: Thu, 15 Oct 2020 00:53:06 +0800 Subject: [PATCH 3/7] 0.17.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6979f492..49478d1b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chatie/grpc", - "version": "0.17.4", + "version": "0.17.5", "description": "gRPC for Chatie", "main": "dist/src/index.js", "typings": "dist/src/index.d.js", From 83ddfd3e0d22fa8c4089252dd5f08a3f9c3b29db Mon Sep 17 00:00:00 2001 From: windmemory Date: Thu, 15 Oct 2020 10:49:53 +0800 Subject: [PATCH 4/7] add imageType to MessageImageStreamRequest --- proto/wechaty/puppet/message.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/proto/wechaty/puppet/message.proto b/proto/wechaty/puppet/message.proto index a7cdc9c9..ef7acb38 100644 --- a/proto/wechaty/puppet/message.proto +++ b/proto/wechaty/puppet/message.proto @@ -58,6 +58,7 @@ message MessageImageResponse { message MessageImageStreamRequest { string id = 1; + ImageType type = 2; } message MessageImageStreamResponse { bytes data = 1; From a094e563e3e2f50f005bc11175f060971880b347 Mon Sep 17 00:00:00 2001 From: windmemory Date: Thu, 15 Oct 2020 12:55:07 +0800 Subject: [PATCH 5/7] add @deprecated to MessageFile and MessageImage rpc --- proto/wechaty/puppet.proto | 2 ++ 1 file changed, 2 insertions(+) diff --git a/proto/wechaty/puppet.proto b/proto/wechaty/puppet.proto index a9305c2e..6340b413 100644 --- a/proto/wechaty/puppet.proto +++ b/proto/wechaty/puppet.proto @@ -92,8 +92,10 @@ service Puppet { rpc MessagePayload (puppet.MessagePayloadRequest) returns (puppet.MessagePayloadResponse) {} rpc MessageContact (puppet.MessageContactRequest) returns (puppet.MessageContactResponse) {} + // @deprecated: using MessageFileStream to transfer files rpc MessageFile (puppet.MessageFileRequest) returns (puppet.MessageFileResponse) {} rpc MessageFileStream (puppet.MessageFileStreamRequest) returns (stream puppet.MessageFileStreamResponse) {} + // @deprecated: using MessageImageStream to transfer images rpc MessageImage (puppet.MessageImageRequest) returns (puppet.MessageImageResponse) {} rpc MessageImageStream (puppet.MessageImageStreamRequest) returns (stream puppet.MessageImageStreamResponse) {} rpc MessageMiniProgram (puppet.MessageMiniProgramRequest) returns (puppet.MessageMiniProgramResponse) {} From d4ee3939237ccb910b705e5a6cd556de82cadfc9 Mon Sep 17 00:00:00 2001 From: windmemory Date: Thu, 15 Oct 2020 12:58:18 +0800 Subject: [PATCH 6/7] add change history in readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 1c31cc58..ee02bd36 100644 --- a/README.md +++ b/README.md @@ -221,6 +221,9 @@ TCP hole punching ## HISTORY +### v0.18 (Oct 15, 2020) +- Add new `MessageFileStream` and `MessageImageStream` to replace the `MessageFile` and `MessageImage` method to avoid blocking nodejs event loop when sending large files ([#88](https://github.com/Chatie/grpc/pull/88)) by [@windmemory](https://github.com/windmemory) + ### v0.17 (Aug 5, 2020) - Add PHPH Support ([#76](https://github.com/Chatie/grpc/pull/76) [#78](https://github.com/Chatie/grpc/pull/78)) by [@zhangchunsheng](https://github.com/zhangchunsheng) From 9bd0d86e2c40067dca21fae50284d156541eb127 Mon Sep 17 00:00:00 2001 From: windmemory Date: Thu, 15 Oct 2020 12:58:26 +0800 Subject: [PATCH 7/7] 0.18.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 49478d1b..b2c2ec6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chatie/grpc", - "version": "0.17.5", + "version": "0.18.0", "description": "gRPC for Chatie", "main": "dist/src/index.js", "typings": "dist/src/index.d.js",