mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-06-29 06:20:32 +08:00
手机可见性bugfix
This commit is contained in:
parent
28f1ef9dcb
commit
58defe6373
@ -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)
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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 {
|
||||
|
||||
2
protocol
2
protocol
@ -1 +1 @@
|
||||
Subproject commit 7eb7737531d6ff779571e77f5a49aa21ce9bcb43
|
||||
Subproject commit 510b9a7dc27703beab55334622e4ecf17b8a4d50
|
||||
Loading…
x
Reference in New Issue
Block a user