Skip to content

Commit

Permalink
Add capability to filter by room status
Browse files Browse the repository at this point in the history
To address https://osu.ppy.sh/community/forums/topics/2013293.

Normally wouldn't detour for this but the second message in that thread
pissed me off. I feel like people will start to exploit this now so
maybe I shouldn't admit to it.
  • Loading branch information
bdach committed Dec 11, 2024
1 parent 642e973 commit 458542d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/Models/Multiplayer/Room.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class Room extends Model
const PLAYLIST_QUEUE_MODE = 'host_only';
const REALTIME_DEFAULT_QUEUE_MODE = 'host_only';
const REALTIME_QUEUE_MODES = [ 'host_only', 'all_players', 'all_players_round_robin' ];
const REALTIME_STATUSES = ['idle', 'playing'];

public ?array $preloadedRecentParticipants = null;

Expand Down Expand Up @@ -149,6 +150,7 @@ public static function search(array $rawParams, ?int $maxLimit = null)
'mode',
'season_id:int',
'sort',
'status',
'type_group',
'user:any',
], ['null_missing' => true]);
Expand All @@ -157,6 +159,7 @@ public static function search(array $rawParams, ?int $maxLimit = null)
$user = $params['user'];
$seasonId = $params['season_id'];
$sort = $params['sort'];
$status = $params['status'];
$category = $params['category'];
$typeGroup = $params['type_group'];

Expand All @@ -173,6 +176,14 @@ public static function search(array $rawParams, ?int $maxLimit = null)

$query = static::whereIn('type', static::TYPE_GROUPS[$typeGroup]);

if (!in_array($status, static::REALTIME_STATUSES)) {

Check failure on line 179 in app/Models/Multiplayer/Room.php

View workflow job for this annotation

GitHub Actions / Lint all

Strict parameter missing in in_array() call.
$status = null;
}

if (isset($status)) {
$query->where('status', $status);
}

if (isset($seasonId)) {
$query->whereRelation('seasons', 'seasons.id', $seasonId);
}
Expand Down

0 comments on commit 458542d

Please sign in to comment.