mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-03 02:42:19 +08:00
fix: fix the error
This commit is contained in:
parent
624f0c8f59
commit
63f6c085d9
2
go.mod
2
go.mod
@ -155,4 +155,4 @@ require (
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
)
|
||||
|
||||
replace github.com/OpenIMSDK/protocol => github.com/luhaoling/protocol v0.0.0-20231216114224-9af361a90b6b
|
||||
replace github.com/OpenIMSDK/protocol => github.com/luhaoling/protocol v0.0.0-20231223094538-101234d675fc
|
||||
|
||||
4
go.sum
4
go.sum
@ -225,8 +225,8 @@ github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205Ah
|
||||
github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw=
|
||||
github.com/lithammer/shortuuid v3.0.0+incompatible h1:NcD0xWW/MZYXEHa6ITy6kaXN5nwm/V115vj2YXfhS0w=
|
||||
github.com/lithammer/shortuuid v3.0.0+incompatible/go.mod h1:FR74pbAuElzOUuenUHTK2Tciko1/vKuIKS9dSkDrA4w=
|
||||
github.com/luhaoling/protocol v0.0.0-20231216114224-9af361a90b6b h1:/Qw8Cr8P7dyTCA2vHbWZE+5T6cEF2DHIoAgouM31t/E=
|
||||
github.com/luhaoling/protocol v0.0.0-20231216114224-9af361a90b6b/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
|
||||
github.com/luhaoling/protocol v0.0.0-20231223094538-101234d675fc h1:Uj5oqXMbQDqBPnjZAjaycS0Fsf3thIjjGhYzkKDJIJk=
|
||||
github.com/luhaoling/protocol v0.0.0-20231223094538-101234d675fc/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
|
||||
|
||||
@ -18,7 +18,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/OpenIMSDK/protocol/sdkws"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/localcache"
|
||||
"sort"
|
||||
|
||||
"github.com/OpenIMSDK/tools/tx"
|
||||
@ -44,10 +43,8 @@ import (
|
||||
)
|
||||
|
||||
type conversationServer struct {
|
||||
Conversation *rpcclient.ConversationRpcClient
|
||||
MsgDatabase controller.CommonMsgDatabase
|
||||
MsgRpcClient *rpcclient.MessageRpcClient
|
||||
User *rpcclient.UserRpcClient
|
||||
ConversationLocalCache *localcache.ConversationLocalCache
|
||||
groupRpcClient *rpcclient.GroupRpcClient
|
||||
conversationDatabase controller.ConversationDatabase
|
||||
conversationNotificationSender *notification.ConversationNotificationSender
|
||||
@ -100,43 +97,43 @@ func (m *conversationServer) GetConversationList(ctx context.Context, req *pbcon
|
||||
} else {
|
||||
conversationIDs = req.ConversationIDs
|
||||
}
|
||||
log.ZDebug(ctx, "GetConversationList1", "seqs", req, "userID", req.UserID)
|
||||
log.ZDebug(ctx, "GetConversationList1", "seqs", req, "conversationIDs", conversationIDs)
|
||||
|
||||
conversations, err := m.conversationDatabase.FindConversations(ctx, req.UserID, conversationIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.ZDebug(ctx, "GetConversationList2", "seqs", req, "userID", req.UserID)
|
||||
log.ZDebug(ctx, "GetConversationList2", "seqs", req, "conversations", conversations)
|
||||
|
||||
maxSeqs, err := m.MsgDatabase.GetMaxSeqs(ctx, conversationIDs)
|
||||
maxSeqs, err := m.MsgRpcClient.GetMaxSeqs(ctx, conversationIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.ZDebug(ctx, "GetConversationList3", "seqs", req, "userID", req.UserID)
|
||||
log.ZDebug(ctx, "GetConversationList3", "seqs", req, "maxSeqs", maxSeqs)
|
||||
|
||||
chatLogs, err := m.MsgDatabase.FindOneByDocIDs(ctx, conversationIDs, maxSeqs)
|
||||
chatLogs, err := m.MsgRpcClient.GetMsgByConversationIDs(ctx, conversationIDs, maxSeqs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.ZDebug(ctx, "GetConversationList4", "seqs", req, "userID", req.UserID)
|
||||
log.ZDebug(ctx, "GetConversationList4", "seqs", req, "chatLogs", chatLogs)
|
||||
|
||||
conversationMsg, err := m.getConversationInfo(ctx, chatLogs, req.UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.ZDebug(ctx, "GetConversationList5", "seqs", req, "userID", req.UserID)
|
||||
log.ZDebug(ctx, "GetConversationList5", "seqs", req, "conversationMsg", conversationMsg)
|
||||
|
||||
hasReadSeqs, err := m.MsgDatabase.GetHasReadSeqs(ctx, req.UserID, conversationIDs)
|
||||
hasReadSeqs, err := m.MsgRpcClient.GetHasReadSeqs(ctx, req.UserID, conversationIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.ZDebug(ctx, "GetConversationList6", "seqs", req, "userID", req.UserID)
|
||||
log.ZDebug(ctx, "GetConversationList6", "seqs", req, "hasReadSeqs", hasReadSeqs)
|
||||
|
||||
conversation_unreadCount := make(map[string]int64)
|
||||
for conversationID, maxSeq := range maxSeqs {
|
||||
conversation_unreadCount[conversationID] = maxSeq - hasReadSeqs[conversationID]
|
||||
}
|
||||
log.ZDebug(ctx, "GetConversationList7", "seqs", req, "userID", req.UserID)
|
||||
log.ZDebug(ctx, "GetConversationList7", "seqs", req, "conversation_unreadCount", conversation_unreadCount)
|
||||
|
||||
conversation_isPinkTime := make(map[int64]string)
|
||||
conversation_notPinkTime := make(map[int64]string)
|
||||
@ -154,10 +151,10 @@ func (m *conversationServer) GetConversationList(ctx context.Context, req *pbcon
|
||||
resp = &pbconversation.GetConversationListResp{
|
||||
ConversationElems: []*pbconversation.ConversationElem{},
|
||||
}
|
||||
log.ZDebug(ctx, "GetConversationList8", "seqs", req, "userID", req.UserID)
|
||||
|
||||
m.conversationSort(conversation_isPinkTime, resp, conversation_unreadCount, conversationMsg)
|
||||
m.conversationSort(conversation_notPinkTime, resp, conversation_unreadCount, conversationMsg)
|
||||
log.ZDebug(ctx, "GetConversationList8", "seqs", req, "resp", resp)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
|
||||
@ -30,3 +30,27 @@ func (m *msgServer) GetConversationMaxSeq(
|
||||
}
|
||||
return &pbmsg.GetConversationMaxSeqResp{MaxSeq: maxSeq}, nil
|
||||
}
|
||||
|
||||
func (m *msgServer) GetMaxSeqs(ctx context.Context, req *pbmsg.GetMaxSeqsReq) (*pbmsg.SeqsInfoResp, error) {
|
||||
maxSeqs, err := m.MsgDatabase.GetMaxSeqs(ctx, req.ConversationIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pbmsg.SeqsInfoResp{MaxSeqs: maxSeqs}, nil
|
||||
}
|
||||
|
||||
func (m *msgServer) GetHasReadSeqs(ctx context.Context, req *pbmsg.GetHasReadSeqsReq) (*pbmsg.SeqsInfoResp, error) {
|
||||
hasReadSeqs, err := m.MsgDatabase.GetHasReadSeqs(ctx, req.UserID, req.ConversationIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pbmsg.SeqsInfoResp{MaxSeqs: hasReadSeqs}, nil
|
||||
}
|
||||
|
||||
func (m *msgServer) GetMsgByConversationIDs(ctx context.Context, req *pbmsg.GetMsgByConversationIDsReq) (*pbmsg.GetMsgByConversationIDsResp, error) {
|
||||
Msgs, err := m.MsgDatabase.FindOneByDocIDs(ctx, req.ConversationIDs, req.MaxSeqs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pbmsg.GetMsgByConversationIDsResp{MsgDatas: Msgs}, nil
|
||||
}
|
||||
|
||||
@ -155,6 +155,29 @@ func (m *MessageRpcClient) GetMaxSeq(ctx context.Context, req *sdkws.GetMaxSeqRe
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (m *MessageRpcClient) GetMaxSeqs(ctx context.Context, conversationIDs []string) (map[string]int64, error) {
|
||||
resp, err := m.Client.GetMaxSeqs(ctx, &msg.GetMaxSeqsReq{
|
||||
ConversationIDs: conversationIDs,
|
||||
})
|
||||
return resp.MaxSeqs, err
|
||||
}
|
||||
|
||||
func (m *MessageRpcClient) GetHasReadSeqs(ctx context.Context, userID string, conversationIDs []string) (map[string]int64, error) {
|
||||
resp, err := m.Client.GetHasReadSeqs(ctx, &msg.GetHasReadSeqsReq{
|
||||
UserID: userID,
|
||||
ConversationIDs: conversationIDs,
|
||||
})
|
||||
return resp.MaxSeqs, err
|
||||
}
|
||||
|
||||
func (m *MessageRpcClient) GetMsgByConversationIDs(ctx context.Context, docIDs []string, seqs map[string]int64) (map[string]*sdkws.MsgData, error) {
|
||||
resp, err := m.Client.GetMsgByConversationIDs(ctx, &msg.GetMsgByConversationIDsReq{
|
||||
ConversationIDs: docIDs,
|
||||
MaxSeqs: seqs,
|
||||
})
|
||||
return resp.MsgDatas, err
|
||||
}
|
||||
|
||||
func (m *MessageRpcClient) PullMessageBySeqList(ctx context.Context, req *sdkws.PullMessageBySeqsReq) (*sdkws.PullMessageBySeqsResp, error) {
|
||||
resp, err := m.Client.PullMessageBySeqs(ctx, req)
|
||||
return resp, err
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user