im.proto

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);
}

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

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

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

// 同步关系-请求
message ReqRelationSync {
    // 客户端当前seqno
    uint64 client_relation_oplog_seqno = 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 ReqSyncAck {
    //
    uint64 client_seqno = 1;
}

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

// 同步版本拉取消息-请求
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 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 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 ReqNewSessions {
    //
    uint64 begin_ts = 1;
    //
    uint32 size = 2;
    //
    uint32 teenager_mode = 3;
    // 课堂模式
    uint32 lessons_mode = 4;
}

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

// 拉取消息-响应
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;
}

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

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

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

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

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

//
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; //
}

// 未读私信数-请求
message ReqSingleUnread {
    //
    uint32 unread_type = 1;
    //
    uint32 show_unfollow_list = 2;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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