mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-07-25 00:55:42 +08:00
手机可见性bugfix
This commit is contained in:
parent
1a361405cc
commit
47aa96989c
@ -15,21 +15,23 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (s *friendServer) NotificationUserInfoUpdate(ctx context.Context, req *relation.NotificationUserInfoUpdateReq) (*relation.NotificationUserInfoUpdateResp, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(userIDs) > 0 {
|
if len(ownerUserIDs) > 0 {
|
||||||
friendUserIDs := []string{req.UserID}
|
friendUserIDs := []string{req.UserID}
|
||||||
noCancelCtx := context.WithoutCancel(ctx)
|
noCancelCtx := context.WithoutCancel(ctx)
|
||||||
err := s.queue.PushCtx(ctx, func() {
|
err := s.queue.PushCtx(ctx, func() {
|
||||||
for _, userID := range userIDs {
|
for _, ownerUserID := range ownerUserIDs {
|
||||||
if err := s.db.OwnerIncrVersion(noCancelCtx, userID, friendUserIDs, model.VersionStateUpdate); err != nil {
|
if err := s.db.OwnerIncrVersion(noCancelCtx, ownerUserID, friendUserIDs, model.VersionStateUpdate); err != nil {
|
||||||
log.ZError(ctx, "OwnerIncrVersion", err, "userID", userID, "friendUserIDs", friendUserIDs)
|
log.ZError(ctx, "OwnerIncrVersion", err, "userID", ownerUserID, "friendUserIDs", friendUserIDs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, userID := range userIDs {
|
for _, ownerUserID := range ownerUserIDs {
|
||||||
s.notificationSender.FriendInfoUpdatedNotification(noCancelCtx, req.UserID, userID)
|
s.notificationSender.FriendInfoUpdatedNotification(noCancelCtx, req.UserID, ownerUserID)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -185,6 +185,7 @@ func (s *userServer) applyPhoneVisibility(ctx context.Context, viewerID string,
|
|||||||
for i, db := range dbUsers {
|
for i, db := range dbUsers {
|
||||||
pb := pbUsers[i]
|
pb := pbUsers[i]
|
||||||
if db.Phone == "" {
|
if db.Phone == "" {
|
||||||
|
pb.AreaCode = ""
|
||||||
// 未设置手机号,直接跳过
|
// 未设置手机号,直接跳过
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -194,6 +195,7 @@ func (s *userServer) applyPhoneVisibility(ctx context.Context, viewerID string,
|
|||||||
case tablerelation.PhoneVisibilityHidden:
|
case tablerelation.PhoneVisibilityHidden:
|
||||||
// 完全隐藏:即使本人也不通过此接口暴露,客户端自行从个人设置接口获取
|
// 完全隐藏:即使本人也不通过此接口暴露,客户端自行从个人设置接口获取
|
||||||
pb.Phone = ""
|
pb.Phone = ""
|
||||||
|
pb.AreaCode = ""
|
||||||
case tablerelation.PhoneVisibilityFriends:
|
case tablerelation.PhoneVisibilityFriends:
|
||||||
// 仅好友可见
|
// 仅好友可见
|
||||||
if viewerID == db.UserID {
|
if viewerID == db.UserID {
|
||||||
@ -208,9 +210,11 @@ func (s *userServer) applyPhoneVisibility(ctx context.Context, viewerID string,
|
|||||||
}
|
}
|
||||||
if !isFriend {
|
if !isFriend {
|
||||||
pb.Phone = ""
|
pb.Phone = ""
|
||||||
|
pb.AreaCode = ""
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
pb.Phone = ""
|
pb.Phone = ""
|
||||||
|
pb.AreaCode = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -335,6 +339,13 @@ func (s *userServer) SetPhoneVisibility(ctx context.Context, req *pbuser.SetPhon
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.friendNotificationSender.UserInfoUpdatedNotification(ctx, req.UserID)
|
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
|
return &pbuser.SetPhoneVisibilityResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user