From 58defe63733f38630700d251ecf30b3c957c7c2f Mon Sep 17 00:00:00 2001 From: hawklin2017 <32898629+hawklin2017@users.noreply.github.com> Date: Tue, 19 May 2026 17:43:44 +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/api/friend.go | 4 ++++ internal/api/router.go | 1 + internal/rpc/relation/friend.go | 25 +++++++++++++++++++++++++ internal/rpc/relation/sync.go | 17 ++++++++--------- protocol | 2 +- 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/internal/api/friend.go b/internal/api/friend.go index 6932c495b..491fadf20 100644 --- a/internal/api/friend.go +++ b/internal/api/friend.go @@ -101,6 +101,10 @@ func (o *FriendApi) GetSpecifiedFriendsInfo(c *gin.Context) { a2r.Call(c, relation.FriendClient.GetSpecifiedFriendsInfo, o.Client) } +func (o *FriendApi) GetFriendPhone(c *gin.Context) { + a2r.Call(c, relation.FriendClient.GetFriendPhone, o.Client) +} + func (o *FriendApi) UpdateFriends(c *gin.Context) { a2r.Call(c, relation.FriendClient.UpdateFriends, o.Client) } diff --git a/internal/api/router.go b/internal/api/router.go index ed0dc0bde..42fb67731 100644 --- a/internal/api/router.go +++ b/internal/api/router.go @@ -216,6 +216,7 @@ func newGinRouter(ctx context.Context, client discovery.SvcDiscoveryRegistry, co friendRouterGroup.POST("/is_friend", f.IsFriend) friendRouterGroup.POST("/get_friend_id", f.GetFriendIDs) friendRouterGroup.POST("/get_specified_friends_info", f.GetSpecifiedFriendsInfo) + friendRouterGroup.POST("/get_phone", f.GetFriendPhone) friendRouterGroup.POST("/update_friends", f.UpdateFriends) friendRouterGroup.POST("/get_incremental_friends", f.GetIncrementalFriends) friendRouterGroup.POST("/get_full_friend_user_ids", f.GetFullFriendUserIDs) diff --git a/internal/rpc/relation/friend.go b/internal/rpc/relation/friend.go index 737be75f2..40d4112ed 100644 --- a/internal/rpc/relation/friend.go +++ b/internal/rpc/relation/friend.go @@ -597,6 +597,31 @@ func (s *friendServer) GetSpecifiedFriendsInfo(ctx context.Context, req *relatio return resp, nil } +// GetFriendPhone 返回 friendUserID 对应用户的 Phone、AreaCode。 +// 是否下发明文仅由该用户(friendUserID)设置的 phone_visibility 决定(经 User.GetDesignateUsers / applyPhoneVisibility,viewer 为 ctx 中的 opUserID)。 +// 非本人查询时,要求 friendUserID 须在 ownerUserID 的好友列表中。 +func (s *friendServer) GetFriendPhone(ctx context.Context, req *relation.GetFriendPhoneReq) (*relation.GetFriendPhoneResp, error) { + if err := authverify.CheckAccessV3(ctx, req.OwnerUserID, s.config.Share.IMAdminUserID); err != nil { + return nil, err + } + if req.OwnerUserID != req.FriendUserID { + if _, err := s.db.FindFriendsWithError(ctx, req.OwnerUserID, []string{req.FriendUserID}); err != nil { + return nil, err + } + } + userInfo, err := s.userClient.GetUserInfo(ctx, req.FriendUserID) + if err != nil { + return nil, err + } + if userInfo == nil { + return nil, errs.ErrRecordNotFound.WrapMsg("user not found") + } + return &relation.GetFriendPhoneResp{ + Phone: userInfo.Phone, + AreaCode: userInfo.AreaCode, + }, nil +} + func (s *friendServer) UpdateFriends( ctx context.Context, req *relation.UpdateFriendsReq, diff --git a/internal/rpc/relation/sync.go b/internal/rpc/relation/sync.go index 3b63f647c..1255bed81 100644 --- a/internal/rpc/relation/sync.go +++ b/internal/rpc/relation/sync.go @@ -15,23 +15,22 @@ import ( ) func (s *friendServer) NotificationUserInfoUpdate(ctx context.Context, req *relation.NotificationUserInfoUpdateReq) (*relation.NotificationUserInfoUpdateResp, error) { - // 单向好友:仅通知「好友列表中包含 req.UserID」的用户(owner -> req.UserID), - // 而非 req.UserID 自己好友列表中的对端。 - ownerUserIDs, err := s.db.FindFriendUserID(ctx, req.UserID) + + userIDs, err := s.db.FindFriendUserIDs(ctx, req.UserID) if err != nil { return nil, err } - if len(ownerUserIDs) > 0 { + if len(userIDs) > 0 { friendUserIDs := []string{req.UserID} noCancelCtx := context.WithoutCancel(ctx) err := s.queue.PushCtx(ctx, func() { - 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 { + 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 { - s.notificationSender.FriendInfoUpdatedNotification(noCancelCtx, req.UserID, ownerUserID) + for _, userID := range userIDs { + s.notificationSender.FriendInfoUpdatedNotification(noCancelCtx, req.UserID, userID) } }) if err != nil { diff --git a/protocol b/protocol index 7eb773753..510b9a7dc 160000 --- a/protocol +++ b/protocol @@ -1 +1 @@ -Subproject commit 7eb7737531d6ff779571e77f5a49aa21ce9bcb43 +Subproject commit 510b9a7dc27703beab55334622e4ecf17b8a4d50