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 "google/protobuf/timestamp.proto";

/**
 * @deprecated
 *  Huan(202109): will be removed after Dec 31, 2022
 *    https://cloud.google.com/apis/design/design_patterns#optional_primitive_fields
 */
import "google/protobuf/wrappers.proto";

import "wechaty/puppet/image.proto";
import "wechaty/puppet/location.proto";
import "wechaty/puppet/mini-program.proto";
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";
import "wechaty/puppet/channel-card.proto";

enum MessageType { // 消息类型
  MESSAGE_TYPE_UNSPECIFIED   = 0;

  MESSAGE_TYPE_ATTACHMENT    = 1;  // 文件消息
  MESSAGE_TYPE_AUDIO         = 2;  // 音频
  MESSAGE_TYPE_CONTACT       = 3;  // 名片
  MESSAGE_TYPE_CHAT_HISTORY  = 4;  // 聊天记录，wxwork暂不支持
  MESSAGE_TYPE_EMOTCION      = 5;  // 表情
  MESSAGE_TYPE_IMAGE         = 6;  // 图片
  MESSAGE_TYPE_TEXT          = 7;  // 文本
  MESSAGE_TYPE_LOCATION      = 8;  // 地址
  MESSAGE_TYPE_MINI_PROGRAM  = 9;  // 小程序
  MESSAGE_TYPE_GROUP_NOTE    = 10; // 群接龙消息，wxwork中没有
  MESSAGE_TYPE_TRANSFER      = 11; // 转账，wxwork中没有
  MESSAGE_TYPE_RED_ENVELOPE  = 12; // 红包，wxwork中没有
  MESSAGE_TYPE_RECALLED      = 13; // 撤回
  MESSAGE_TYPE_URL           = 14; // 链接
  MESSAGE_TYPE_VIDEO         = 15; // 视频
  MESSAGE_TYPE_POST          = 16; // 特殊的复合类型，wxwork中没有
  MESSAGE_TYPE_CHANNEL       = 17; // 视频号
  MESSAGE_TYPE_SYSTEM        = 18; // 系统消息
  MESSAGE_TYPE_MARKDOWN      = 19; // MarkDown
  MESSAGE_TYPE_CALL_RECORD   = 20; // 通话记录
  MESSAGE_TYPE_CHANNEL_CARD  = 21; // 视频号名片
}

enum TextContentType {
  TEXT_CONTENT_TYPE_REGULAR = 0;
  TEXT_CONTENT_TYPE_AT = 1;
}

message TextContentData {
  string contact_id = 1;
}

message TextContent {
  TextContentType type = 1;
  string text = 2;
  TextContentData data = 3;
}

message MessagePayloadRequest {
  string id = 1;
}
message MessagePayloadResponse {
  string      id                 = 1;
  string      filename           = 2; // 文件名
  string      text               = 3; // 文本内容
  /**
   * @deprecated will be removed after Dec 31, 2022
   *  Huan(202109): use receive_time(10) instead
   */
  uint64      timestamp_deprecated = 4 [deprecated = true];
  MessageType type               = 5; // 类型
  string      talker_id          = 6; // 发送者id
  string      room_id            = 7; // 群聊id
  string      listener_id        = 8; // 接受者id
  repeated    string mention_ids = 9; // 群消息@人的id列表
  google.protobuf.Timestamp receive_time = 10; // 收到消息时间
  optional string quote_id       = 11; // 被引用的消息id

  optional string additional_info = 12;

  repeated TextContent text_contents = 13;
}

message MessageImageRequest {
  string    id   = 1;
  ImageType type = 2; // 获取图片的类型（缩略图、原图）
}
message MessageImageResponse {
   string file_box = 1;
}

message MessageContactRequest {
  string id = 1;
}
message MessageContactResponse {
  string id = 1;
}

message MessageFileRequest {
  string id = 1;
}
message MessageFileResponse {
   string file_box = 1;
}

message MessageVoiceRequest {
  string id = 1;
}
message MessageVoiceResponse {
   string file_box = 1;
}

message MessageVoiceTextRequest {
  string id = 1;
}
message MessageVoiceTextResponse {
   string text      = 1;
   bool   no_speech = 2;
}

message MessageMiniProgramRequest {
  string id = 1;
}
message MessageMiniProgramResponse {
  /**
   * Huan(202110): We should use payload instead of JSON.stringify string
   *  The compatible code will be removed after Dec 31, 2022
   */
  string mini_program_deprecated = 1 [deprecated = true]; // deprecated after Sep 31, 2021, remove compatible code after Dec 31, 2022
  MiniProgramPayload mini_program = 2;
}

message MessageUrlRequest {
  string id = 1;
}
message MessageUrlResponse {
  /**
   * Huan(202110): We should use payload instead of JSON.stringify string
   *  The compatible code will be removed after Dec 31, 2022
   */
  string url_link_deprecated = 1 [deprecated = true]; // deprecated after Sep 31, 2021, remove compatible code after Dec 31, 2022
  UrlLinkPayload url_link = 2;
}

message MessageChannelRequest {
  string id = 1;
}
message MessageChannelResponse {
  ChannelPayload channel = 1;
}

message MessageChannelCardRequest {
  string id = 1;
}
message MessageChannelCardResponse {
  ChannelCardPayload channel_card = 1;
}

message MessageCallRecordRequest {
  string id = 1;
}
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;
  string contact_id = 2;
}
message MessageSendContactResponse {
  /**
   * @deprecated:
   *  Huan(202109): Wrapper types must not be used going forward.
   *    https://cloud.google.com/apis/design/design_patterns#optional_primitive_fields
   */
  google.protobuf.StringValue id_string_value_deprecated = 1 [deprecated = true]; // Deprecated after Sep 31, 2021, will be removed after Dec 31, 2022
  string id = 2;
}

message MessageSendFileRequest {
  string conversation_id = 1; // 对话id
  string file_box = 2; // 发送文件的fileBox.toJSON()
}
message MessageSendFileResponse {
  /**
   * @deprecated:
   *  Huan(202109): Wrapper types must not be used going forward.
   *    https://cloud.google.com/apis/design/design_patterns#optional_primitive_fields
   */
  google.protobuf.StringValue id_string_value_deprecated = 1 [deprecated = true]; // Deprecated after Sep 31, 2021, will be removed after Dec 31, 2022
  string id = 2;
}

message MessageSendTextRequest { // 发文本消息
  string conversation_id = 1; // 对话id
  string text = 2; // 文本内容
  repeated string mentional_ids = 3; // @人id列表
  optional string quote_id = 4; // 引用消息的id
}
message MessageSendTextResponse {
  /**
   * @deprecated:
   *  Huan(202109): Wrapper types must not be used going forward.
   *    https://cloud.google.com/apis/design/design_patterns#optional_primitive_fields
   */
  google.protobuf.StringValue id_string_value_deprecated = 1 [deprecated = true]; // Deprecated after Sep 31, 2021, will be removed after Dec 31, 2022
  string id = 2;
}

message MessageBatchSendTextRequest {
  repeated string conversation_ids = 1;
  string text = 2;
  optional string batch_task_id = 3;
}
message MessageBatchSendTextResponse {
  message Result {
    string conversation_id = 1;
    optional string id = 2;
    optional string error = 3;
  }
  repeated Result results = 1;
}

message MessageBatchSendFileRequest {
  repeated string conversation_ids = 1;
  string file_box = 2;
  optional string batch_task_id = 3;
}
message MessageBatchSendFileResponse {
  message Result {
    string conversation_id = 1;
    optional string id = 2;
    optional string error = 3;
  }
  repeated Result results = 1;
}

message MessageBatchForwardRequest {
  repeated string conversation_ids = 1;
  string message_id = 2 [deprecated = true];
  repeated string message_ids = 3;
  optional string batch_task_id = 4;
}
message MessageBatchForwardResponse {
  message Result {
    string conversation_id = 1;
    optional string id = 2;
    optional string error = 3;
  }
  repeated Result results = 1;
}

message MessageBatchSendContactRequest {
  repeated string conversation_ids = 1;
  string contact_id = 2;
  optional string batch_task_id = 3;
}
message MessageBatchSendContactResponse {
  message Result {
    string conversation_id = 1;
    optional string id = 2;
    optional string error = 3;
  }
  repeated Result results = 1;
}

message MessageBatchSendUrlRequest {
  repeated string conversation_ids = 1;
  UrlLinkPayload url_link = 2;
  optional string batch_task_id = 3;
}
message MessageBatchSendUrlResponse {
  message Result {
    string conversation_id = 1;
    optional string id = 2;
    optional string error = 3;
  }
  repeated Result results = 1;
}

message MessageBatchSendMiniProgramRequest {
  repeated string conversation_ids = 1;
  MiniProgramPayload mini_program = 2;
  optional string batch_task_id = 3;
}
message MessageBatchSendMiniProgramResponse {
  message Result {
    string conversation_id = 1;
    optional string id = 2;
    optional string error = 3;
  }
  repeated Result results = 1;
}

message MessageBatchSendLocationRequest {
  repeated string conversation_ids = 1;
  LocationPayload location = 2;
  optional string batch_task_id = 3;
}
message MessageBatchSendLocationResponse {
  message Result {
    string conversation_id = 1;
    optional string id = 2;
    optional string error = 3;
  }
  repeated Result results = 1;
}

message MessageBatchSendChannelRequest {
  repeated string conversation_ids = 1;
  ChannelPayload channel = 2;
  optional string batch_task_id = 3;
}
message MessageBatchSendChannelResponse {
  message Result {
    string conversation_id = 1;
    optional string id = 2;
    optional string error = 3;
  }
  repeated Result results = 1;
}

message MessageBatchSendChannelCardRequest {
  repeated string conversation_ids = 1;
  ChannelCardPayload channel_card = 2;
  optional string batch_task_id = 3;
}
message MessageBatchSendChannelCardResponse {
  message Result {
    string conversation_id = 1;
    optional string id = 2;
    optional string error = 3;
  }
  repeated Result results = 1;
}

message MessageSendMiniProgramRequest {
  string conversation_id = 1; // 对话id
  /**
   * Huan(202110): We should use payload instead of JSON.stringify string
   *  The compatible code will be removed after Dec 31, 2022
   */
  string mini_program_deprecated = 2 [deprecated = true]; // deprecated after Sep 31, 2021, remove compatible code after Dec 31, 2022
  MiniProgramPayload mini_program = 3; // 小程序payload
}
message MessageSendMiniProgramResponse {
  /**
   * @deprecated:
   *  Huan(202109): Wrapper types must not be used going forward.
   *    https://cloud.google.com/apis/design/design_patterns#optional_primitive_fields
   */
  google.protobuf.StringValue id_string_value_deprecated = 1 [deprecated = true]; // Deprecated after Sep 31, 2021, will be removed after Dec 31, 2022
  string id = 2;
}

message MessageSendUrlRequest {
  string conversation_id = 1; // 对话id
  /**
   * Huan(202110): We should use payload instead of JSON.stringify string
   *  The compatible code will be removed after Dec 31, 2022
   */
  string url_link_deprecated = 2 [deprecated = true]; // deprecated after Sep 31, 2021, remove compatible code after Dec 31, 2022
  UrlLinkPayload url_link = 3; // 链接payload
}
message MessageSendUrlResponse {
  /**
   * @deprecated:
   *  Huan(202109): Wrapper types must not be used going forward.
   *    https://cloud.google.com/apis/design/design_patterns#optional_primitive_fields
   */
  google.protobuf.StringValue id_string_value_deprecated = 1 [deprecated = true]; // Deprecated after Sep 31, 2021, will be removed after Dec 31, 2022
  string id = 2;
}

message MessageSendPostRequest {
  string conversation_id = 1; // 对话id
  PostPayloadClient content = 2; // 发送的post内容
}

message MessageSendPostResponse {
  string id = 1;
}

message MessageRecallRequest {
  string id = 1;
}
message MessageRecallResponse {
  bool success = 1;
}
message MessageForwardRequest{
  // @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 {
  /**
   * @deprecated: use payload instead.
   *  Huan(202109): Wrapper types must not be used going forward.
   *    https://cloud.google.com/apis/design/design_patterns#optional_primitive_fields
   */
  google.protobuf.StringValue id_string_value_deprecated = 1 [deprecated = true]; // Deprecated after Sep 31, 2021, will be removed after Dec 31, 2022
  string id = 2;
}

message MessageLocationRequest{
  string id = 1;
}
message MessageLocationResponse {
  LocationPayload location = 1;
}

message MessageSendLocationRequest {
  string conversation_id = 1;
  LocationPayload location = 2;
}
message MessageSendLocationResponse {
  /**
   * Huan(202110): we will not use wrappers any more by following the Google Style Guide:
   *  If not using optional would add complexity or ambiguity, then use optional primitive fields,
   *  Wrapper types must not be used going forward.
   *  — Optional Primitive Fields (https://cloud.google.com/apis/design/design_patterns.md#optional-primitive-fields)
   */
  string id = 1;
}

message MessageSendChannelRequest {
  string conversation_id = 1;
  ChannelPayload channel = 2;
}
message MessageSendChannelResponse {
  string id = 1;
}

message MessageSendChannelCardRequest {
  string conversation_id = 1;
  ChannelCardPayload channel_card = 2;
}
message MessageSendChannelCardResponse {
  string id = 1;
}

message MessagePreviewRequest {
  string id = 1;
}

message MessagePreviewResponse {
  string file_box = 1;
}

message GetMessageBroadcastTargetRequest {}

message GetMessageBroadcastTargetResponse {
  repeated string contact_ids = 1;
  repeated string room_ids = 2;
}

message CreateMessageBroadcastRequest {
  repeated string target_ids = 1;
  PostPayloadClient content = 2;
}

message CreateMessageBroadcastResponse {
  string id = 1;
}

enum BroadcastStatus {
  BROADCAST_STATUS_UNKNOWN = 0;
  BROADCAST_STATUS_SENDING = 1;
  BROADCAST_STATUS_SENT = 2;
}

enum BroadcastTargetStatus {
  BROADCAST_TARGET_STATUS_UNSENT = 0;
  BROADCAST_TARGET_STATUS_SENT = 1;
  BROADCAST_TARGET_STATUS_NOT_FRIEND = 2;
  BROADCAST_TARGET_STATUS_OCCUPIED = 3;
}

message BroadcastTarget {
  string contact_id = 1;
  string room_id = 2;
  BroadcastTargetStatus status = 3;
}

message GetMessageBroadcastStatusRequest {
  string id = 1;
}

message GetMessageBroadcastStatusResponse {
  BroadcastStatus status = 1;
  repeated BroadcastTarget detail = 2;
}
