From 47aa96989c5e590219431dde765663a2d182960f Mon Sep 17 00:00:00 2001 From: hawklin2017 <32898629+hawklin2017@users.noreply.github.com> Date: Tue, 19 May 2026 15:35:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=8B=E6=9C=BA=E5=8F=AF=E8=A7=81=E6=80=A7bu?= =?UTF-8?q?gfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/rpc/relation/sync.go | 16 +++++++++------- internal/rpc/user/user.go | 11 +++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/internal/rpc/relation/sync.go b/internal/rpc/relation/sync.go index ee0c86496..3b63f647c 100644 --- a/internal/rpc/relation/sync.go +++ b/internal/rpc/relation/sync.go @@ -15,21 +15,23 @@ import ( ) func (s *friendServer) NotificationUserInfoUpdate(ctx context.Context, req *relation.NotificationUserInfoUpdateReq) (*relation.NotificationUserInfoUpdateResp, error) { - userIDs, err := s.db.FindFriendUserIDs(ctx, req.UserID) + // 单向好友:仅通知「好友列表中包含 req.UserID」的用户(owner -> req.UserID), + // 而非 req.UserID 自己好友列表中的对端。 + ownerUserIDs, err := s.db.FindFriendUserID(ctx, req.UserID) if err != nil { return nil, err } - if len(userIDs) > 0 { + if len(ownerUserIDs) > 0 { friendUserIDs := []string{req.UserID} noCancelCtx := context.WithoutCancel(ctx) err := s.queue.PushCtx(ctx, func() { - for _, userID := range userIDs { - if err := s.db.OwnerIncrVersion(noCancelCtx, userID, friendUserIDs, model.VersionStateUpdate); err != nil { - log.ZError(ctx, "OwnerIncrVersion", err, "userID", userID, "friendUserIDs", friendUserIDs) + for _, ownerUserID := range ownerUserIDs { + if err := s.db.OwnerIncrVersion(noCancelCtx, ownerUserID, friendUserIDs, model.VersionStateUpdate); err != nil { + log.ZError(ctx, "OwnerIncrVersion", err, "userID", ownerUserID, "friendUserIDs", friendUserIDs) } } - for _, userID := range userIDs { - s.notificationSender.FriendInfoUpdatedNotification(noCancelCtx, req.UserID, userID) + for _, ownerUserID := range ownerUserIDs { + s.notificationSender.FriendInfoUpdatedNotification(noCancelCtx, req.UserID, ownerUserID) } }) if err != nil { diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index 607d586e8..cf15b6374 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -185,6 +185,7 @@ func (s *userServer) applyPhoneVisibility(ctx context.Context, viewerID string, for i, db := range dbUsers { pb := pbUsers[i] if db.Phone == "" { + pb.AreaCode = "" // 未设置手机号,直接跳过 continue } @@ -194,6 +195,7 @@ func (s *userServer) applyPhoneVisibility(ctx context.Context, viewerID string, case tablerelation.PhoneVisibilityHidden: // 完全隐藏:即使本人也不通过此接口暴露,客户端自行从个人设置接口获取 pb.Phone = "" + pb.AreaCode = "" case tablerelation.PhoneVisibilityFriends: // 仅好友可见 if viewerID == db.UserID { @@ -208,9 +210,11 @@ func (s *userServer) applyPhoneVisibility(ctx context.Context, viewerID string, } if !isFriend { pb.Phone = "" + pb.AreaCode = "" } default: pb.Phone = "" + pb.AreaCode = "" } } return nil @@ -335,6 +339,13 @@ func (s *userServer) SetPhoneVisibility(ctx context.Context, req *pbuser.SetPhon return nil, err } s.friendNotificationSender.UserInfoUpdatedNotification(ctx, req.UserID) + + if _, err := s.relationClient.NotificationUserInfoUpdate(ctx, &friendpb.NotificationUserInfoUpdateReq{ + UserID: req.UserID, + }); err != nil { + log.ZError(ctx, "SetPhoneVisibility: NotificationUserInfoUpdate failed", err, "userID", req.UserID) + return nil, err + } return &pbuser.SetPhoneVisibilityResp{}, nil }