syntax = "proto2";
//package mars.stn;


option java_package = "cn.wildfirechat.proto";
option java_outer_classname = "WFCMessage";
//option optimize_for = LITE_RUNTIME;


message AddFriendRequest {
    required string target_uid = 1;
    required string reason = 2;
}

message Conversation {
    required int32 type = 1;
    required string target = 2;
    required int32 line = 3;
}

message GroupInfo {
    optional string target_id = 1;
    required string name = 2;
    optional string portrait = 3;
    optional string owner = 4;
    required int32 type = 5;
    optional int32 member_count = 6;
    optional string extra = 7;
    optional int64 update_dt = 8;
    optional int64 member_update_dt = 9;
}


message GroupMember {
    required string member_id = 1;
    optional string alias = 2;
    required int32 type = 3;
    optional int64 update_dt = 4;
}

message Group {
    required GroupInfo group_info = 1;
    repeated GroupMember members = 2;
}

message ChannelInfo {
    optional string target_id = 1;
    required string name = 2;
    optional string portrait = 3;
    optional string owner = 4;
    //0, public; 1, private; 2 closed;
    optional int32 status = 5;
    optional string desc = 6;
    optional string extra = 7;
    optional int64 update_dt = 8;
    optional string secret = 9;
    optional string callback = 10;
    optional int32 automatic = 11;
}

message ModifyChannelInfo {
    required string channel_id = 1;
    required int32 type = 2;
    required string value = 3;
}

message TransferChannel {
    required string channel_id = 1;
    required string new_owner = 2;
}

message PullChannelInfo {
    required string channel_id = 1;
    required int64 head = 2;
}

message PullChannelListener {
    required string channel_id = 1;
    required int32 offset = 2;
    required int32 count = 3;
}

message PullChannelListenerResult {
    required int32 total_count = 1;
    required int32 offset = 2;
    repeated string listener = 3;
}

message ListenChannel {
    required string channel_id = 1;
    required int32 listen = 2;
}

message SearchChannelResult {
    repeated ChannelInfo channel = 1;
    required string keyword = 2;
}

message MessageContent {
    required int32 type = 1;
    optional string searchable_content = 2;
    optional string push_content = 3;
    optional string content = 4;
    optional bytes data = 5;
    optional int32 mediaType = 6;
    optional string remoteMediaUrl = 7;
    optional int32 persist_flag= 8;
    optional int32 expire_duration= 9;
    optional int32 mentioned_type= 10;
    repeated string mentioned_target= 11;
}

message AddGroupMemberRequest {
    required string group_id = 1;
    repeated GroupMember added_member = 2;
    repeated int32 to_line = 3;
    optional MessageContent notify_content = 4;
}

message CreateGroupRequest {
    required Group group = 1;
    repeated int32 to_line = 2;
    optional MessageContent notify_content = 3;
}

message DismissGroupRequest {
    required string group_id = 1;
    repeated int32 to_line = 2;
    optional MessageContent notify_content = 3;
}

message FriendRequest {
    optional string from_uid = 1;
    required string to_uid = 2;
    required string reason = 3;
    optional int32 status = 4;
    optional int64 update_dt = 5;
    optional bool from_read_status = 6;
    optional bool to_read_status = 7;
}

message GeneralResult {
    required int32 error_code = 1;
}

message GetUploadTokenResult {
    required string domain = 1;
    required string token = 2;
    required string server = 3;
}

message HandleFriendRequest {
    required string target_uid = 1;
    required int32 status = 2;
}

message IDBuf {
    required string id = 1;
}

message IDListBuf {
    repeated string id = 1;
}

message Message {
    required Conversation conversation = 1;
    required string from_user = 2;
    required MessageContent content = 3;
    optional int64 message_id = 4;
    optional int64 server_timestamp = 5;
    optional string to_user = 6;
}

message User {
    required string uid = 1;
    optional string name = 2;
    optional string display_name = 3;
    optional string portrait = 4;
    optional string mobile = 5;
    optional string email = 6;
    optional string address = 7;
    optional string company = 8;
    optional string extra = 9;
    optional int64 update_dt = 10;
    optional int32 gender = 11;
    optional string social = 12;
     //0 normal user; 1 robot
    optional int32 type = 13;
}

message Robot {
    required string uid = 1;
    //0 normal; 1 deleted;
    required int32 state = 2;
    optional string owner = 3;
    optional string secret = 4;
    optional string callback = 5;
    optional string extra = 6;
}

message GetRobotsResult {
    repeated Robot entry = 1;
}

message Thing {
    required string uid = 1;
    //0 normal; 1 deleted;
    required int32 state = 2;
    required string token = 3;
    optional string owner = 4;
    optional string extra = 5;
}

message GetThingsResult {
    repeated Thing entry = 1;
}

message UploadDeviceTokenRequest {
    required int32 platform = 1;
    required string app_name = 2;
    required string device_token = 3;
    required int32 push_type = 4;
}

message ModifyGroupInfoRequest {
    required string group_id = 1;
    required int32 type = 2;
    required string value = 3;
    repeated int32 to_line = 4;
    optional MessageContent notify_content = 5;
}

message InfoEntry {
    required int32 type = 1;
    required string value = 2;
}

message ModifyMyInfoRequest {
    repeated InfoEntry entry = 1;
}

message NotifyMessage {
    required int32 type = 1;
    required int64 head = 2;
    optional string target = 3;
}

message PullMessageRequest {
    required int64 id = 1;
    required int32 type = 2;
    optional int64 delay = 3;
}

message PullMessageResult {
    repeated Message message = 1;
    required int64 current = 2;
    required int64 head = 3;
}

message PullGroupInfoResult {
    repeated GroupInfo info = 1;
}

message PullGroupMemberRequest {
    required string target = 1;
    required int64 head = 2;
}

message PullGroupMemberResult {
    repeated GroupMember member = 1;
}

message UserRequest {
    required string uid = 1;
    optional int64 update_dt = 2;
}

message PullUserRequest {
    repeated UserRequest request = 1;
}

message UserResult {
    required User user = 1;
    required int32 code = 2;
}


message PullUserResult {
    repeated UserResult result = 1;
}

message QuitGroupRequest {
    required string group_id = 1;
    repeated int32 to_line = 2;
    optional MessageContent notify_content = 3;
}

message RemoveGroupMemberRequest {
    required string group_id = 1;
    repeated string removed_member = 2;
    repeated int32 to_line = 3;
    optional MessageContent notify_content = 4;
}

message TransferGroupRequest {
    required string group_id = 1;
    required string new_owner = 2;
    repeated int32 to_line = 3;
    optional MessageContent notify_content = 4;
}

message ModifyGroupMemberAlias {
    required string group_id = 1;
    required string alias = 2;
    repeated int32 to_line = 3;
    optional MessageContent notify_content = 4;
}

message UserSettingEntry {
    required int32 scope = 1;
    required string key = 2;
    required string value = 3;
    required int64 update_dt = 4;
}

message ModifyUserSettingReq {
    required int32 scope = 1;
    required string key = 2;
    required string value = 3;
}

message Version {
  required int64 version = 1;
}

message GetUserSettingResult {
    repeated UserSettingEntry entry = 1;
}

message Friend {
  required string uid = 1;
  required int32 state = 2;
  required int64 update_dt = 3;
}

message GetFriendsResult {
    repeated Friend entry = 1;
}

message GetFriendRequestResult {
    repeated FriendRequest entry = 1;
}

message ConnectAckPayload {
    optional int64 msg_head = 1;
    optional int64 friend_head = 2;
    optional int64 friend_rq_head = 3;
    optional int64 setting_head = 4;
    optional string node_addr = 5;
    optional int32 node_port = 6;
    optional int64 server_time = 7;
}

message IMHttpWrapper {
    required string token = 1;
    required string client_id = 2;
    required string request = 3;
    optional bytes data = 4;
}

message SearchUserRequest {
    required string keyword = 1;
    optional int32 fuzzy = 2;
    optional int32 page = 3;
}

message SearchUserResult {
    repeated User entry = 1;
}

message GetChatroomInfoRequest {
    required string chatroom_id = 1;
    optional int64 update_dt = 2;
}

message ChatroomInfo {
    required string title = 1;
    optional string desc = 2;
    optional string portrait = 3;
    optional int32 member_count = 4;
    optional int64 create_dt = 5;
    optional int64 update_dt = 6;
    optional string extra = 7;
    optional int32 state = 8;
}

message GetChatroomMemberInfoRequest {
    required string chatroom_id = 1;
    optional int32 max_count = 2;
}

message ChatroomMemberInfo {
    optional int32 member_count = 1;
    repeated string members = 2;
}

message INT64Buf {
    required int64 id = 1;
}

message NotifyRecallMessage {
    required int64 id = 1;
    required string from_user = 2;
}

message BlackUserRequest {
  required string uid = 1;
  required int32 status = 2;
}

message RouteRequest {
  optional string app = 1;
  optional int32 platform = 2;
  optional int32 push_type = 3;
  optional string device_name = 4;
  optional string device_version = 5;
  optional string phone_name = 6;
  optional string language = 7;
  optional string carrier_name = 8;
  optional string app_version = 9;
  optional string sdk_version = 10;
}

message RouteResponse {
  required string host = 1;
  required int32 long_port = 2;
  required int32 short_port = 3;
}

message GetTokenRequest {
  required string user_id = 1;
  required string client_id = 2;
}
