From 534a63f4275188eb2eaa6b0cf278f8d0dce81acb Mon Sep 17 00:00:00 2001 From: luhaoling <2198702716@qq.com> Date: Sat, 23 Dec 2023 18:47:04 +0800 Subject: [PATCH] fix: fix the rpc error --- internal/rpc/conversation/conversaion.go | 15 +++++++++------ pkg/rpcclient/msg.go | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/internal/rpc/conversation/conversaion.go b/internal/rpc/conversation/conversaion.go index 973b43f45..9e107dd74 100644 --- a/internal/rpc/conversation/conversaion.go +++ b/internal/rpc/conversation/conversaion.go @@ -43,8 +43,8 @@ import ( ) type conversationServer struct { - MsgRpcClient *rpcclient.MessageRpcClient - User *rpcclient.UserRpcClient + msgRpcClient *rpcclient.MessageRpcClient + user *rpcclient.UserRpcClient groupRpcClient *rpcclient.GroupRpcClient conversationDatabase controller.ConversationDatabase conversationNotificationSender *notification.ConversationNotificationSender @@ -65,7 +65,10 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e } groupRpcClient := rpcclient.NewGroupRpcClient(client) msgRpcClient := rpcclient.NewMessageRpcClient(client) + userRpcClient := rpcclient.NewUserRpcClient(client) pbconversation.RegisterConversationServer(server, &conversationServer{ + msgRpcClient: &msgRpcClient, + user: &userRpcClient, conversationNotificationSender: notification.NewConversationNotificationSender(&msgRpcClient), groupRpcClient: &groupRpcClient, 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) - maxSeqs, err := m.MsgRpcClient.GetMaxSeqs(ctx, conversationIDs) + maxSeqs, err := m.msgRpcClient.GetMaxSeqs(ctx, conversationIDs) if err != nil { return nil, err } 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 { return nil, err } @@ -123,7 +126,7 @@ func (m *conversationServer) GetConversationList(ctx context.Context, req *pbcon } 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 { return nil, err } @@ -476,7 +479,7 @@ func (c *conversationServer) getConversationInfo( } } if len(sendIDs) != 0 { - sendInfos, err := c.User.GetUsersInfo(ctx, sendIDs) + sendInfos, err := c.user.GetUsersInfo(ctx, sendIDs) if err != nil { return nil, err } diff --git a/pkg/rpcclient/msg.go b/pkg/rpcclient/msg.go index 0a14de03e..c0dbd033e 100644 --- a/pkg/rpcclient/msg.go +++ b/pkg/rpcclient/msg.go @@ -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) { - log.ZDebug(ctx, "GetMaxSeqs", "seqs", "conversations", conversationIDs) + log.ZDebug(ctx, "GetMaxSeqs", "conversationIDs", conversationIDs) resp, err := m.Client.GetMaxSeqs(ctx, &msg.GetMaxSeqsReq{ ConversationIDs: conversationIDs, })