fix: fix the rpc error

pull/1672/head
luhaoling 2 years ago
parent 45f161c95f
commit 534a63f427

@ -43,8 +43,8 @@ import (
) )
type conversationServer struct { type conversationServer struct {
MsgRpcClient *rpcclient.MessageRpcClient msgRpcClient *rpcclient.MessageRpcClient
User *rpcclient.UserRpcClient user *rpcclient.UserRpcClient
groupRpcClient *rpcclient.GroupRpcClient groupRpcClient *rpcclient.GroupRpcClient
conversationDatabase controller.ConversationDatabase conversationDatabase controller.ConversationDatabase
conversationNotificationSender *notification.ConversationNotificationSender conversationNotificationSender *notification.ConversationNotificationSender
@ -65,7 +65,10 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
} }
groupRpcClient := rpcclient.NewGroupRpcClient(client) groupRpcClient := rpcclient.NewGroupRpcClient(client)
msgRpcClient := rpcclient.NewMessageRpcClient(client) msgRpcClient := rpcclient.NewMessageRpcClient(client)
userRpcClient := rpcclient.NewUserRpcClient(client)
pbconversation.RegisterConversationServer(server, &conversationServer{ pbconversation.RegisterConversationServer(server, &conversationServer{
msgRpcClient: &msgRpcClient,
user: &userRpcClient,
conversationNotificationSender: notification.NewConversationNotificationSender(&msgRpcClient), conversationNotificationSender: notification.NewConversationNotificationSender(&msgRpcClient),
groupRpcClient: &groupRpcClient, groupRpcClient: &groupRpcClient,
conversationDatabase: controller.NewConversationDatabase(conversationDB, cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), conversationDB), tx.NewMongo(mongo.GetClient())), conversationDatabase: controller.NewConversationDatabase(conversationDB, cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), conversationDB), tx.NewMongo(mongo.GetClient())),
@ -105,13 +108,13 @@ func (m *conversationServer) GetConversationList(ctx context.Context, req *pbcon
} }
log.ZDebug(ctx, "GetConversationList2", "seqs", req, "conversations", conversations) log.ZDebug(ctx, "GetConversationList2", "seqs", req, "conversations", conversations)
maxSeqs, err := m.MsgRpcClient.GetMaxSeqs(ctx, conversationIDs) maxSeqs, err := m.msgRpcClient.GetMaxSeqs(ctx, conversationIDs)
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.ZDebug(ctx, "GetConversationList3", "seqs", req, "maxSeqs", maxSeqs) log.ZDebug(ctx, "GetConversationList3", "seqs", req, "maxSeqs", maxSeqs)
chatLogs, err := m.MsgRpcClient.GetMsgByConversationIDs(ctx, conversationIDs, maxSeqs) chatLogs, err := m.msgRpcClient.GetMsgByConversationIDs(ctx, conversationIDs, maxSeqs)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -123,7 +126,7 @@ func (m *conversationServer) GetConversationList(ctx context.Context, req *pbcon
} }
log.ZDebug(ctx, "GetConversationList5", "seqs", req, "conversationMsg", conversationMsg) log.ZDebug(ctx, "GetConversationList5", "seqs", req, "conversationMsg", conversationMsg)
hasReadSeqs, err := m.MsgRpcClient.GetHasReadSeqs(ctx, req.UserID, conversationIDs) hasReadSeqs, err := m.msgRpcClient.GetHasReadSeqs(ctx, req.UserID, conversationIDs)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -476,7 +479,7 @@ func (c *conversationServer) getConversationInfo(
} }
} }
if len(sendIDs) != 0 { if len(sendIDs) != 0 {
sendInfos, err := c.User.GetUsersInfo(ctx, sendIDs) sendInfos, err := c.user.GetUsersInfo(ctx, sendIDs)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -156,7 +156,7 @@ func (m *MessageRpcClient) GetMaxSeq(ctx context.Context, req *sdkws.GetMaxSeqRe
} }
func (m *MessageRpcClient) GetMaxSeqs(ctx context.Context, conversationIDs []string) (map[string]int64, error) { func (m *MessageRpcClient) GetMaxSeqs(ctx context.Context, conversationIDs []string) (map[string]int64, error) {
log.ZDebug(ctx, "GetMaxSeqs", "seqs", "conversations", conversationIDs) log.ZDebug(ctx, "GetMaxSeqs", "conversationIDs", conversationIDs)
resp, err := m.Client.GetMaxSeqs(ctx, &msg.GetMaxSeqsReq{ resp, err := m.Client.GetMaxSeqs(ctx, &msg.GetMaxSeqsReq{
ConversationIDs: conversationIDs, ConversationIDs: conversationIDs,
}) })

Loading…
Cancel
Save