From 7e9728afc49532b1d76e7555ad86c8d2e001db75 Mon Sep 17 00:00:00 2001 From: suchang Date: Mon, 9 Oct 2023 19:18:55 +0800 Subject: [PATCH] feat: :sparkles: send/get chat history --- commonjs/generated/puppet.cjs | 1 + commonjs/generated/puppet.cjs.d.ts | 1 + proto/wechaty/puppet.proto | 5 +++ proto/wechaty/puppet/chat-history.proto | 43 +++++++++++++++++++++++++ proto/wechaty/puppet/message.proto | 12 ++++++- 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 proto/wechaty/puppet/chat-history.proto diff --git a/commonjs/generated/puppet.cjs b/commonjs/generated/puppet.cjs index 6079e63..e782472 100644 --- a/commonjs/generated/puppet.cjs +++ b/commonjs/generated/puppet.cjs @@ -20,6 +20,7 @@ const puppetFileList = [ '../../out/wechaty/puppet/util_pb.js', '../../out/wechaty/puppet/verify-code_pb.js', '../../out/wechaty/puppet/call_pb.js', + '../../out/wechaty/puppet/chat-history_pb.js', '../../out/wechaty/puppet_grpc_pb.js', '../../out/wechaty/puppet_pb.js', diff --git a/commonjs/generated/puppet.cjs.d.ts b/commonjs/generated/puppet.cjs.d.ts index 664e390..dad10af 100644 --- a/commonjs/generated/puppet.cjs.d.ts +++ b/commonjs/generated/puppet.cjs.d.ts @@ -42,6 +42,7 @@ export * from '../../out/wechaty/puppet/conversation_pb.js' export * from '../../out/wechaty/puppet/util_pb.js' export * from '../../out/wechaty/puppet/verify-code_pb.js' export * from '../../out/wechaty/puppet/call_pb.js' +export * from '../../out/wechaty/puppet/chat-history_pb.js' export * from '../../out/wechaty/puppet_grpc_pb.js' export * from '../../out/wechaty/puppet_pb.js' diff --git a/proto/wechaty/puppet.proto b/proto/wechaty/puppet.proto index 94ce98c..f4f7807 100644 --- a/proto/wechaty/puppet.proto +++ b/proto/wechaty/puppet.proto @@ -363,6 +363,11 @@ service Puppet { get: "/message/{id}/call-record" }; } + rpc MessageChatHistory (puppet.MessageChatHistoryRequest) returns (puppet.MessageChatHistoryResponse) { + option (google.api.http) = { + get: "/message/{id}/chat-history" + }; + } rpc MessageRecall (puppet.MessageRecallRequest) returns (puppet.MessageRecallResponse) { option (google.api.http) = { put: "/message/{id}/recall" diff --git a/proto/wechaty/puppet/chat-history.proto b/proto/wechaty/puppet/chat-history.proto new file mode 100644 index 0000000..d911501 --- /dev/null +++ b/proto/wechaty/puppet/chat-history.proto @@ -0,0 +1,43 @@ +syntax = "proto3"; +package wechaty.puppet; + +option go_package = "github.com/wechaty/go-grpc/wechaty/puppet"; +option java_package = "io.github.wechaty.grpc.puppet"; +option csharp_namespace = "github.wechaty.grpc.puppet"; + +import "location.proto"; +import "mini-program.proto"; +import "url-link.proto"; +import "channel.proto"; +import "message.proto"; + +enum ChatHistoryContentType { + TEXT = 0; + FILE = 1; + LOCATION = 2; + URL = 3; + MINI_PROGRAM = 4; + CHANNEL = 5; + CHAT_HISTORY = 6; +} + +message ChatHistoryContent { + ChatHistoryContentType type = 1; + string text = 2; + string file_box = 3; + LocationPayload location = 4; + UrlLinkPayload url_link = 5; + MiniProgramPayload mini_program = 6; + ChannelPayload channel = 7; + repeated ChatHistoryPayload chat_history = 8; +} + + +message ChatHistoryPayload { + MessageType type = 1; + string avatar = 2; + string sender_name = 3; + string corp_name = 4; + string time = 5; + ChatHistoryContent message = 6; +} diff --git a/proto/wechaty/puppet/message.proto b/proto/wechaty/puppet/message.proto index 5daa416..74c7a67 100644 --- a/proto/wechaty/puppet/message.proto +++ b/proto/wechaty/puppet/message.proto @@ -21,6 +21,7 @@ import "wechaty/puppet/url-link.proto"; import "wechaty/puppet/channel.proto"; import "wechaty/puppet/post.proto"; import "wechaty/puppet/call.proto"; +import "wechaty/puppet/chat-history.proto"; enum MessageType { // 消息类型 @@ -131,6 +132,13 @@ message MessageCallRecordResponse { CallRecordPayload call_record = 1; } +message MessageChatHistoryRequest { + string id = 1; +} +message MessageChatHistoryResponse { + repeated ChatHistoryPayload chat_history_list = 1; +} + message MessageSendContactRequest { string conversation_id = 1; @@ -221,8 +229,10 @@ message MessageRecallResponse { bool success = 1; } message MessageForwardRequest{ - string message_id = 1; // 要转发的消息id + // @deprecated: use message_ids instead. + string message_id = 1 [deprecated = true]; // 要转发的消息id string conversation_id = 2; // 对话id + repeated string message_ids = 3; // 要合并转发的消息id列表 } message MessageForwardResponse { /**