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";

enum MessageType {
  MESSAGE_TYPE_UNSPECIFIED  = 0;

  MESSAGE_TYPE_ATTACHMENT   = 1;
  MESSAGE_TYPE_AUDIO        = 2;
  MESSAGE_TYPE_CONTACT      = 3;
  MESSAGE_TYPE_EMOTICON     = 4;
  MESSAGE_TYPE_IMAGE        = 5;
  MESSAGE_TYPE_TEXT         = 6;
  MESSAGE_TYPE_VIDEO        = 7;
  MESSAGE_TYPE_CHAT_HISTORY = 8;
  MESSAGE_TYPE_LOCATION     = 9;
  MESSAGE_TYPE_MINI_PROGRAM = 10;
  MESSAGE_TYPE_TRANSFER     = 11;
  MESSAGE_TYPE_RED_ENVELOPE = 12;
  MESSAGE_TYPE_RECALLED     = 13;
  MESSAGE_TYPE_URL          = 14;
}

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      from_id            = 6;
  string      room_id            = 7;
  string      to_id              = 8;
  repeated    string mention_ids = 9;
  google.protobuf.Timestamp receive_time = 10;
}

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 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 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;
  string file_box = 2;
}
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;
  string text = 2;

  // Huan(202011) FIXME: Issue #99
  // https://github.com/wechaty/grpc/issues/99
  repeated string mentional_ids = 3;
}
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 MessageSendMiniProgramRequest {
  string conversation_id = 1;
  /**
   * 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;
}
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;
  /**
   * 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;
}
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 MessageRecallRequest {
  string id = 1;
}
message MessageRecallResponse {
  bool success = 1;
}
message MessageForwardRequest{
  string message_id = 1;
  string conversation_id = 2;
}
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;
}
