From c67c6cea39a9b047d7ae8919a412ffcd46ccf983 Mon Sep 17 00:00:00 2001 From: nanaya Date: Fri, 13 Dec 2024 20:07:55 +0900 Subject: [PATCH] Require multiplayer api to join multiplayer room --- app/Singletons/OsuAuthorize.php | 10 +++------- tests/Controllers/Chat/ChannelsControllerTest.php | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/Singletons/OsuAuthorize.php b/app/Singletons/OsuAuthorize.php index 92143f27e22..27c14d000e0 100644 --- a/app/Singletons/OsuAuthorize.php +++ b/app/Singletons/OsuAuthorize.php @@ -1027,7 +1027,7 @@ public function checkChatChannelRead(?User $user, Channel $channel): string * @return string * @throws AuthorizationCheckException */ - public function checkChatChannelJoin(?User $user, Channel $channel): string + public function checkChatChannelJoin(?User $user, Channel $channel): ?string { $prefix = 'chat.'; @@ -1039,13 +1039,9 @@ public function checkChatChannelJoin(?User $user, Channel $channel): string $this->ensureCleanRecord($user, $prefix); - // This check is only for when joining the channel directly; joining via the Room - // will always add the user to the channel. + // joining multiplayer room is done through room endpoint if ($channel->isMultiplayer()) { - $room = Room::hasParticipated($user)->find($channel->room_id); - if ($room !== null) { - return 'ok'; - } + return null; } // allow joining of 'tournament' matches (for lazer/tournament client) diff --git a/tests/Controllers/Chat/ChannelsControllerTest.php b/tests/Controllers/Chat/ChannelsControllerTest.php index dac9bbc3b51..6b097bcc1cf 100644 --- a/tests/Controllers/Chat/ChannelsControllerTest.php +++ b/tests/Controllers/Chat/ChannelsControllerTest.php @@ -205,7 +205,7 @@ public function testChannelJoinMultiplayerWhenParticipated() 'user' => $this->user->getKey(), ])); - $request->assertStatus(200)->assertJsonFragment(['channel_id' => $scoreLink->playlistItem->room->channel_id, 'type' => Channel::TYPES['multiplayer']]); + $request->assertStatus(403); } //endregion