syntax = "proto3";

package bilibili.im.interfaces.v1;

import "bilibili/im/type/im.proto";

// 私信
service ImInterface {
    // 发送消息
    rpc SendMsg (ReqSendMsg) returns (RspSendMsg);
    // 同步关系
    rpc SyncRelation (ReqRelationSync) returns (RspRelationSync);
    // 确认同步进度
    rpc SyncAck (ReqSyncAck) returns (RspSyncAck);
    // 同步版本拉取消息
    rpc SyncFetchSessionMsgs (ReqSessionMsg) returns (RspSessionMsg);
    // 拉取会话记录列表
    rpc GetSessions (ReqGetSessions) returns (RspSessions);
    // 拉取新消息
    rpc NewSessions (ReqNewSessions) returns (RspSessions);
    // 拉取已读消息
    rpc AckSessions (ReqAckSessions) returns (RspSessions);
    // 更新已读进度
    rpc UpdateAck (ReqUpdateAck) returns (DummyRsp);
    // 置顶聊天
    rpc SetTop (ReqSetTop) returns (DummyRsp);
    // 删除会话记录
    rpc RemoveSession (ReqRemoveSession) returns (DummyRsp);
    // 未读私信数
    rpc SingleUnread (ReqSingleUnread) returns (RspSingleUnread);
    // 我创建的应援团未读数
    rpc MyGroupUnread (DummyReq) returns (RspMyGroupUnread);
    // 未关注的人批量设置为已读
    rpc UpdateUnflwRead (DummyReq) returns (DummyRsp);
    // 应援团消息助手
    rpc GroupAssisMsg (ReqGroupAssisMsg) returns (RspSessionMsg);
    // 更新应援团小助手消息已拉取进度
    rpc AckAssisMsg (ReqAckAssisMsg) returns (DummyRsp);
    // 拉取会话详情
    rpc SessionDetail (ReqSessionDetail) returns (bilibili.im.type.SessionInfo);
    // 批量拉取会话详情
    rpc BatchSessDetail (ReqSessionDetails) returns (RspSessionDetails);
    // 批量删除会话
    rpc BatchRmSessions (ReqBatRmSess) returns (DummyRsp);
    // 拉取最近私信分享列表
    rpc ShareList (ReqShareList) returns (RspShareList);
    //
    rpc SpecificSingleUnread (ReqSpecificSingleUnread) returns (RspSpecificSingleUnread);
    //
    rpc GetSpecificSessions (ReqGetSpecificSessions) returns (RspSessions);
    //
    rpc GetLiveInfo(ReqLiveInfo) returns (RspLiveInfo);
    //
    rpc GetTotalUnread(ReqTotalUnread) returns (RspTotalUnread);      
    //
    rpc ShowClearUnreadUI(ReqShowClearUnreadUI) returns (RspShowClearUnreadUI);
    //
    rpc CloseClearUnreadUI(ReqCloseClearUnreadUI) returns (RspCloseClearUnreadUI);
    //
    rpc UpdateTotalUnread(ReqUpdateTotalUnread) returns (RspUpdateTotalUnread);
}

// 空请求
message DummyReq {
    //
    uint32 idl = 1;
}

// 空响应
message DummyRsp {
    reserved 1;
}

//
enum ENUM_FOLD {
    FOLD_NO = 0;      //
    FOLD_YES = 1;     //
    FOLD_UNKNOWN = 2; //
}

//
enum ENUM_UNREAD_TYPE{
    UNREAD_TYPE_ALL = 0;      //
    UNREAD_TYPE_FOLLOW = 1;   //
    UNREAD_TYPE_UNFOLLOW = 2; //
    UNREAD_TYPE_DUSTBIN = 3;  //
}

// 表情资源信息
message EmotionInfo {
    // 表情
    string text = 1;
    // 表情url
    string url  = 2;
    // 表情大小
    // 0:未知 1:min 2:max
    int32  size = 3;
    // gif url
    string gif_url = 4;
}

//
message MsgDetail {
    //
    int64 msg_key = 1;
    //
    int64 seqno = 2;
}

//
message MsgFeedUnreadRsp {
    //
    map<string, int64> unread = 1;
}

// 更新应援团小助手消息已拉取进度-请求
message ReqAckAssisMsg {
    //
    uint64 ack_seqno = 1;
}

// 拉取已读消息-请求
message ReqAckSessions {
    //
    uint64 begin_ts = 1;
    //
    uint32 end_ts = 2;
    //
    uint32 size = 3;
}

// 批量删除会话-请求
message ReqBatRmSess {

}

//
message ReqCloseClearUnreadUI {

}

//
message ReqGetMsg {
    //
    int64 talker_id = 1;
    //
    int32 session_type = 2;
    //
    repeated MsgDetail msg_detail = 3;
}

// 拉取会话记录列表-请求
message ReqGetSessions {
    //
    uint64 begin_ts = 1;
    //
    uint64 end_ts = 2;
    //
    uint32 size = 3;
    //
    uint32 session_type = 4;
    //
    uint32 unfollow_fold = 5;
    //
    uint32 group_fold = 6;
    //
    uint32 sort_rule = 7;
    // 青少年模式
    uint32 teenager_mode = 8;
    // 课堂模式
    uint32 lessons_mode = 9;
}

// -请求
message ReqGetSpecificSessions {
    // 具体会话详情
    repeated SimpleSession talker_sessions = 1;
}

// 应援团消息助手-请求
message ReqGroupAssisMsg {
    //
    uint64 client_seqno = 1;
    //
    uint32 size = 2;
}

//
message ReqLiveInfo {
    //
    int64 uid = 1;
    //
    int64 talker_id = 2;
}

// 拉取新消息-请求
message ReqNewSessions {
    //
    uint64 begin_ts = 1;
    //
    uint32 size = 2;
    //
    uint32 teenager_mode = 3;
    // 课堂模式
    uint32 lessons_mode = 4;
}

// 同步关系-请求
message ReqRelationSync {
    // 客户端当前seqno
    uint64 client_relation_oplog_seqno = 1;
}

// 删除会话记录-请求
message ReqRemoveSession {
    //
    uint64 talker_id = 1;
    //
    uint32 session_type = 2;
}

// 发送消息-请求
message ReqSendMsg {
    // 消息内容
    bilibili.im.type.Msg msg = 1;
    //
    string cookie = 2;
    //
    string cookie2 = 3;
    //
    int32 error_code = 4;
    //
    string dev_id = 5;
}

// 拉取会话详情-请求
message ReqSessionDetail {
    //
    uint64 talker_id = 1;
    //
    uint32 session_type = 2;
    //
    uint64 uid = 3;
}

// 批量拉取会话详情-请求
message ReqSessionDetails {
    // 会话详情请求列表
    repeated ReqSessionDetail sess_ids = 1;
}

// 同步版本拉取消息-请求
message ReqSessionMsg {
    //
    uint64 talker_id = 1;
    //
    int32 session_type = 2;
    //
    uint64 end_seqno = 3;
    //
    uint64 begin_seqno = 4;
    //
    int32 size = 5;
    //
    int32 order = 6;
    //
    string dev_id = 7;
}

// 置顶聊天-请求
message ReqSetTop {
    //
    uint64 talker_id = 1;
    //
    uint32 session_type = 2;
    //
    // 0:置顶 1:取消置顶
    uint32 op_type = 3;
}

// 拉取最近私信分享列表-请求
message ReqShareList {
    // 分页大小 最大20
    int32 size = 1;
}

//
message ReqShowClearUnreadUI {
    //
    int32 unread_type = 1;
    //
    int32 show_unfollow_list = 2;
    //
    int32 show_dustbin = 4;
}

// 未读私信数-请求
message ReqSingleUnread {
    //
    int32 unread_type = 1;
    //
    int32 show_unfollow_list = 2;
    //
    int64 uid = 3;
    //
    int32 show_dustbin = 4;
}

// -请求
message ReqSpecificSingleUnread {
    // 具体会话详情
    repeated SimpleSession talker_sessions = 1;
}

// 确认同步进度-请求
message ReqSyncAck {
    //
    uint64 client_seqno = 1;
}

//
message ReqTotalUnread {
    //
    int32 unread_type = 1;
    //
    int32 show_unfollow_list = 2;
    //
    int64 uid = 3;
    //
    int32 show_dustbin = 4;
    //
    int32 singleunread_on = 5;
    //
    int32 msgfeed_on = 6;
    //
    int32 sysup_on = 7;
}

// 更新已读进度-请求
message ReqUpdateAck {
    // 聊天对象uid，可以为用户id或者为群id
    uint64 talker_id = 1;    
    // 会话类型
    uint32 session_type = 2;    
    // 已读的最大seqno
    uint64 ack_seqno = 3;
}

//
message ReqUpdateIntercept {
    //
    int64 uid = 1;
    //
    int64 talker_id = 2;
    //
    int32 status = 3;
}

//
message ReqUpdateTotalUnread {

}

//
message RspCloseClearUnreadUI {

}

//
message RspGetMsg {
    //
    repeated bilibili.im.type.Msg msg = 1;
}

//
message RspLiveInfo {
    //
    int64 live_status = 1;
    //
    string jump_url = 2;
}

// 我创建的应援团未读数-响应
message RspMyGroupUnread {
    // 未读消息数
    uint32 unread_count = 1;
}

// 同步关系-响应
message RspRelationSync {
    //
    int32 full = 1;
    // 增量日志
    repeated bilibili.im.type.RelationLog relation_logs = 2;
    // 全量列表
    repeated bilibili.im.type.FriendRelation friend_list = 3;
    // 服务器端最大的relation seqno
    uint64 server_relation_oplog_seqno = 4;
    // 全量列表
    repeated bilibili.im.type.GroupRelation group_list = 5;
}

// 发送消息-响应
message RspSendMsg {
    //
    uint64 msg_key = 1;
    // 表情资源信息
    repeated EmotionInfo e_infos = 2;
    //
    string msg_content = 3;
    //
    bilibili.im.type.KeyHitInfos key_hit_infos = 4;
}

// 批量拉取会话详情-响应
message RspSessionDetails {
    // 会话详情列表
    repeated bilibili.im.type.SessionInfo sess_infos = 1;
}

// 同步版本拉取消息-响应
message RspSessionMsg {
    //
    repeated bilibili.im.type.Msg messages = 1;
    //
    int32 has_more = 2;
    //
    uint64 min_seqno = 3;
    //
    uint64 max_seqno = 4;
    // 表情资源信息
    repeated EmotionInfo e_infos = 5;
}

// 拉取消息-响应
message RspSessions {
    //
    repeated bilibili.im.type.SessionInfo session_list = 1;
    //
    uint32 has_more = 2;
    // 标记反垃圾会话是否在清理中
    bool anti_disturb_cleaning = 3;
    // 当session_list为空时，会返回该字段用于判断通讯录是否为空，1表示空，0表示非空
    int32 is_address_list_empty = 4;
    //
    map<int32, int64> system_msg = 5;
    //
    bool show_level = 6;
}

// 拉取最近私信分享列表-响应
message RspShareList {
    // 最近会话列表
    repeated ShareSessionInfo session_list = 1;
    //
    int32 IsAddressListEmpty = 2;
}

//
message RspShowClearUnreadUI {
    //
    bool display = 1;
    //
    string text = 2;
}

// 未读私信数-响应
message RspSingleUnread {
    // 未关注用户私信数
    uint64 unfollow_unread = 1;
    // 已关注用户私信数
    uint64 follow_unread = 2;
    // 未关注人列表是否有新业务通知
    uint32 unfollow_push_msg = 3;
    //
    int32 dustbin_push_msg = 4;
    //
    int64 dustbin_unread = 5;
}

// -响应
message RspSpecificSingleUnread {
    // key -> 用户uid, value ->未读数
    map <uint64,uint64> talkerUnreadCnt = 1;
    // 总未读数
    uint64 allUnreadCnt = 2;
}

// 确认同步进度-响应
message RspSyncAck {

}

//
message RspTotalUnread {
    //
    SessionSingleUnreadRsp session_single_unread = 1;
    //
    MsgFeedUnreadRsp msg_feed_unread = 2;
    //
    SysMsgInterfaceLastMsgRsp sys_msg_interface_last_msg = 3;
    //
    int32 total_unread = 4;
}

//
message RspUpdateTotalUnread {

}

//
enum SESSION_TYPE {               //
    UNKNOWN         = 0;          //
    UN_FOLD_SESSION = 1;          //
    UN_FOLLOW_SINGLE_SESSION = 2; //
    MY_GROUP_SESSION = 3;         //
    ALL_SESSION = 4;              //
    DUSTBIN_SESSION = 5;          //
}

//
message SessionSingleUnreadRsp {
    //
    int64 unfollow_unread = 1;
    //
    int64 follow_unread = 2;
    //
    int32 unfollow_push_msg = 3;
    //
    int32 dustbin_push_msg = 4;
    //
    int64 dustbin_unread = 5;
}

// 会话信息，用于私信分享
message ShareSessionInfo {
    //
    uint64 talker_id = 1;
    //
    string talker_uname = 2;
    //
    string talker_icon = 3;
    // 认证信息
    // -1: 无认证 0:个人认证 1:机构认证
    int32 official_type = 4;
}

//
message SimpleSession {
    // 聊天对象uid，可以为用户id或者为群id
    uint64 talker_id = 1;
    // 会话类型
    uint32 session_type = 2;
}

//
message SysMsgInterfaceLastMsgRsp {
    //
    int32 unread = 1;
    //
    string title = 2;
    //
    string time = 3;
    //
    int64 id = 4;
}




































