Commit d1b0d80b authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: matchmaking uses raw curl for opponent search (http_build_query was breaking neq filter)

Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent c37f0571
...@@ -62,15 +62,27 @@ function handleQueue($db, string $userId, array $input): void { ...@@ -62,15 +62,27 @@ function handleQueue($db, string $userId, array $input): void {
} }
// Search for available opponent (service key bypasses RLS — can see ALL waiting players) // Search for available opponent (service key bypasses RLS — can see ALL waiting players)
$opponents = $sdb->get('matchmaking_queue', [ // Build URL manually to avoid http_build_query encoding issues
'game_key' => 'eq.' . $gameKey, $searchUrl = SUPABASE_REST . '/matchmaking_queue'
'time_control' => 'eq.' . $timeControl, . '?game_key=eq.' . urlencode($gameKey)
'status' => 'eq.waiting', . '&time_control=eq.' . urlencode($timeControl)
'player_id' => 'neq.' . $userId, . '&status=eq.waiting'
'select' => 'id,player_id,rating', . '&player_id=neq.' . $userId
'order' => 'queued_at.asc', . '&select=id,player_id,rating'
'limit' => 1 . '&order=queued_at.asc'
. '&limit=1';
$ch = curl_init($searchUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'apikey: ' . SUPABASE_SERVICE_KEY,
'Authorization: Bearer ' . SUPABASE_SERVICE_KEY,
'Content-Type: application/json'
]); ]);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$searchResult = curl_exec($ch);
curl_close($ch);
$opponents = json_decode($searchResult, true);
if (!empty($opponents) && !isset($opponents['error']) && isset($opponents[0])) { if (!empty($opponents) && !isset($opponents['error']) && isset($opponents[0])) {
$opponent = $opponents[0]; $opponent = $opponents[0];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment