diff --git a/internal/rpc/relation/friend.go b/internal/rpc/relation/friend.go index a1c2d24cd..3c3c844e0 100644 --- a/internal/rpc/relation/friend.go +++ b/internal/rpc/relation/friend.go @@ -700,15 +700,11 @@ func (s *friendServer) AddOnewayFriend(ctx context.Context, req *relation.ApplyT if err := s.db.BecomeOnewayFriend(ctx, req.FromUserID, req.ToUserID, becomeFriendByOneway, req.Remark); err != nil { return nil, err } - // Notify only A (FromUserID) so incremental friend sync is triggered - // without notifying B (ToUserID). - //tips := sdkws.FriendApplicationApprovedTips{ - // FromToUserID: &sdkws.FromToUserID{ - // FromUserID: req.FromUserID, - // ToUserID: req.ToUserID, - // }, - //} - //s.notificationSender.Notification(ctx, req.FromUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips) + + // Silently notify only A (FromUserID) to trigger an incremental friend-list sync + // so the remark is reflected in the conversation list. + // B (ToUserID) receives no notification of any kind. + s.notificationSender.FriendAddedOnewayNotification(ctx, req.FromUserID, req.ToUserID) return &relation.ApplyToAddFriendResp{}, nil } diff --git a/internal/rpc/relation/notification.go b/internal/rpc/relation/notification.go index 4ee45e197..d9d773c76 100644 --- a/internal/rpc/relation/notification.go +++ b/internal/rpc/relation/notification.go @@ -282,6 +282,19 @@ func (f *FriendNotificationSender) FriendsInfoUpdateNotification(ctx context.Con f.Notification(ctx, toUserID, toUserID, constant.FriendsInfoUpdateNotification, &tips) } +// FriendAddedOnewayNotification silently notifies ownerUserID that friendUserID has been added +// to their friend list (one-way, no consent from friendUserID required). +// isSendMsg=false ensures no visible message appears in either user's conversation list. +func (f *FriendNotificationSender) FriendAddedOnewayNotification(ctx context.Context, ownerUserID, friendUserID string) { + tips := sdkws.FriendsInfoUpdateTips{ + FromToUserID: &sdkws.FromToUserID{ToUserID: ownerUserID}, + FriendIDs: []string{friendUserID}, + } + f.setSortVersion(ctx, &tips.FriendVersion, &tips.FriendVersionID, + database.FriendVersionName, ownerUserID, &tips.FriendSortVersion) + f.Notification(ctx, ownerUserID, ownerUserID, constant.FriendsInfoUpdateNotification, &tips) +} + func (f *FriendNotificationSender) BlackAddedNotification(ctx context.Context, req *relation.AddBlackReq) { tips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}} tips.FromToUserID.FromUserID = req.OwnerUserID