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

import "wechaty/puppet/url-link.proto";
import "wechaty/puppet/channel.proto";
import "wechaty/puppet/location.proto";
import "wechaty/puppet/mini-program.proto";

enum PostType {
  POST_TYPE_UNSPECIFIED = 0;
  POST_TYPE_MOMENT = 1; // 朋友圈
  POST_TYPE_CHANNEL = 2; // 视频号——原始设计走post，实际目前采用message
  POST_TYPE_MESSAGE = 3; // 消息——富媒体消息
  POST_TYPE_BROADCAST = 4; // 群发
  POST_TYPE_TEXT_BUTTON = 5; // puppet-mini 按钮消息
  POST_TYPE_GOODS_CARD = 6; // puppet-mini 商品消息
}

enum SayableType {
  SAYABLE_TYPE_TEXT = 0;
  SAYABLE_TYPE_FILE = 1;
  SAYABLE_TYPE_URL = 2;
  SAYABLE_TYPE_CHANNEL = 3;
  SAYABLE_TYPE_MINIPROGRAM = 4;
}

enum TapType {
  TAP_TYPE_UNSPECIFIED = 0;
  TAP_TYPE_LIKE = 1;
}

message PostSayable {
  SayableType type = 1;

  string id = 2; // 服务器端获取的Post只传回id，异步进行获取
  string text = 3;
  string file_box = 4; // FileBox.toJSON()
  UrlLinkPayload url_link = 5;
  ChannelPayload channel = 6;
  MiniProgramPayload mini_program = 7;

  repeated string mention_id_list = 13; // 文本类型的sayable可传，朋友圈暂不支持
}

message PostPayloadClient {
  string parent_id = 1; // 转发的上一级id,评论时如果是回复，则是回复的评论的id，否则是朋友圈的id
  string root_id = 2; // 转发的根id，评论时应该是朋友圈的id
  PostType type = 3;
  repeated PostSayable sayable_list = 4;

  repeated string visible_list = 5;
  LocationPayload location = 6;
}

message PostPayloadServer {
  string parent_id = 1; // 转发的上一级id
  string root_id = 2; // 转发的根id
  PostType type = 3;
  repeated PostSayable sayable_list = 4;
  string contact_id = 5;
  google.protobuf.Timestamp timestamp = 6;

  // counters 计数器
  int32 children = 7;
  int32 descendant = 8;
  int32 like = 9;

  reserved 10 to 15;

  repeated string visible_list = 16;
  LocationPayload location = 17;
}

message PostTapRequest {
  string post_id = 1;
  TapType type = 2;
  bool tap = 3; // 点赞还是取消
}

message PostTapResponse {
  bool tap = 1;
}

message PostLikeResponse {
  string tap_id = 1;
}

message PostPayloadRequest {
  string post_id = 1;
}

message PostPayloadResponse {
  PostPayloadServer post = 1;
}

message PostPayloadSayableRequest {
  string post_id = 1;
  string sayable_id = 2;
}

message PostPayloadSayableResponse {
  PostSayable sayable = 1;
}
