diff --git a/internal/rpc/msg/server.go b/internal/rpc/msg/server.go index 08786b43b..798ba0ee6 100644 --- a/internal/rpc/msg/server.go +++ b/internal/rpc/msg/server.go @@ -39,7 +39,7 @@ type ( Group *rpcclient.GroupRpcClient User *rpcclient.UserRpcClient Conversation *rpcclient.ConversationRpcClient - friend *rpccache.FriendLocalCache + FriendLocalCache *rpccache.FriendLocalCache GroupLocalCache *rpccache.GroupLocalCache ConversationLocalCache *rpccache.ConversationLocalCache Handlers MessageInterceptorChain @@ -79,6 +79,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e conversationClient := rpcclient.NewConversationRpcClient(client) userRpcClient := rpcclient.NewUserRpcClient(client) groupRpcClient := rpcclient.NewGroupRpcClient(client) + friendRpcClient := rpcclient.NewFriendRpcClient(client) msgDatabase := controller.NewCommonMsgDatabase(msgDocModel, cacheModel) s := &msgServer{ @@ -87,9 +88,9 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e Group: &groupRpcClient, MsgDatabase: msgDatabase, RegisterCenter: client, - GroupLocalCache: rpccache.NewGroupLocalCache(rpcclient.NewGroupRpcClient(client), rdb), - ConversationLocalCache: rpccache.NewConversationLocalCache(rpcclient.NewConversationRpcClient(client), rdb), - friend: rpccache.NewFriendLocalCache(rpcclient.NewFriendRpcClient(client), rdb), + GroupLocalCache: rpccache.NewGroupLocalCache(groupRpcClient, rdb), + ConversationLocalCache: rpccache.NewConversationLocalCache(conversationClient, rdb), + FriendLocalCache: rpccache.NewFriendLocalCache(friendRpcClient, rdb), } s.notificationSender = rpcclient.NewNotificationSender(rpcclient.WithLocalSendMsg(s.SendMsg)) s.addInterceptorHandler(MessageHasReadEnabled) diff --git a/internal/rpc/msg/verify.go b/internal/rpc/msg/verify.go index cd569a3ea..0af56aaa2 100644 --- a/internal/rpc/msg/verify.go +++ b/internal/rpc/msg/verify.go @@ -59,7 +59,7 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe data.MsgData.ContentType >= constant.NotificationBegin { return nil } - black, err := m.friend.IsBlack(ctx, data.MsgData.SendID, data.MsgData.RecvID) + black, err := m.FriendLocalCache.IsBlack(ctx, data.MsgData.SendID, data.MsgData.RecvID) if err != nil { return err } @@ -67,7 +67,7 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe return errs.ErrBlockedByPeer.Wrap() } if *config.Config.MessageVerify.FriendVerify { - friend, err := m.friend.IsFriend(ctx, data.MsgData.SendID, data.MsgData.RecvID) + friend, err := m.FriendLocalCache.IsFriend(ctx, data.MsgData.SendID, data.MsgData.RecvID) if err != nil { return err }