From 16f9c12151a4afc6901074924b5c18730efa4ba1 Mon Sep 17 00:00:00 2001 From: hy001 Date: Tue, 21 Jul 2026 15:22:53 +0800 Subject: [PATCH] feat: allow guest room discovery --- nacos_config/rc-gateway/application.yml | 6 ++++++ .../command/room/query/RoomVoiceDiscoverQryExe.java | 13 +++++++++---- .../query/RoomVoiceProfileByRoomAccountQryExe.java | 4 +++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/nacos_config/rc-gateway/application.yml b/nacos_config/rc-gateway/application.yml index 85a2130f..e7b656ae 100644 --- a/nacos_config/rc-gateway/application.yml +++ b/nacos_config/rc-gateway/application.yml @@ -149,6 +149,12 @@ gateway: - /open-other-test/** - /open-console-test/** - /sys/config/country + # Apple 审核游客模式:只开放首页展示所需的只读接口,进房接口仍要求 token。 + - /sys/config/banner + - /room/live-voice/discovery + - /room/live-voice/search + - /room/profile/specific + - /activity/leaderboard/appLeaderboard - /sys/config/banner/start-page - /oss/sts - /oss/upload diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/query/RoomVoiceDiscoverQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/query/RoomVoiceDiscoverQryExe.java index 34b3cdb0..92643abc 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/query/RoomVoiceDiscoverQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/query/RoomVoiceDiscoverQryExe.java @@ -76,13 +76,18 @@ public class RoomVoiceDiscoverQryExe { public List execute(AppExtCommand cmd) { long totalStart = System.currentTimeMillis(); long stepStart = totalStart; - Long reqUserId = cmd.requiredReqUserId(); + Long reqUserId = cmd.getReqUserId(); String sysOrigin = cmd.requireReqSysOrigin(); - boolean allRegionWhiteListUser = roomRegionFilterCommon.canViewAllRegions(reqUserId); - RegionConfig currentRegion = roomRegionFilterCommon.requireRegionConfig(reqUserId); + boolean guestDiscovery = Objects.isNull(reqUserId); + boolean allRegionWhiteListUser = guestDiscovery + || roomRegionFilterCommon.canViewAllRegions(reqUserId); + // 游客没有账号区域,使用独立 ALL_REGION 缓存浏览公开房间,不参与个性化区域计算。 + RegionConfig currentRegion = guestDiscovery + ? new RegionConfig().setRegionCode("GUEST") + : roomRegionFilterCommon.requireRegionConfig(reqUserId); String region = currentRegion.getRegionCode(); - UserProfile userProfile = userProfileGateway.getByUserId(reqUserId); + UserProfile userProfile = guestDiscovery ? null : userProfileGateway.getByUserId(reqUserId); stepStart = logDiscoveryStep("prepare", stepStart, reqUserId, sysOrigin, region); String key = discoveryCacheKey(sysOrigin, region, allRegionWhiteListUser); diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/query/RoomVoiceProfileByRoomAccountQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/query/RoomVoiceProfileByRoomAccountQryExe.java index c1e0f330..f5ca98ef 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/query/RoomVoiceProfileByRoomAccountQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/query/RoomVoiceProfileByRoomAccountQryExe.java @@ -31,7 +31,9 @@ public class RoomVoiceProfileByRoomAccountQryExe { if (roomVoiceProfile == null || !Objects.equals(roomVoiceProfile.getSysOrigin(), cmd.requireReqSysOrigin())) { return null; } - if (!userRegionGateway.checkEqRegion(cmd.requiredReqUserId(), roomVoiceProfile.getUserId())) { + // 游客只能查看公开房间资料;登录用户仍保持原有同区域搜索限制。 + if (Objects.nonNull(cmd.getReqUserId()) + && !userRegionGateway.checkEqRegion(cmd.getReqUserId(), roomVoiceProfile.getUserId())) { return null; } return roomVoiceProfile;