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 {
}
// Search for available opponent (service key bypasses RLS — can see ALL waiting players)
$opponents = $sdb->get('matchmaking_queue', [
'game_key' => 'eq.' . $gameKey,
'time_control' => 'eq.' . $timeControl,
'status' => 'eq.waiting',
'player_id' => 'neq.' . $userId,
'select' => 'id,player_id,rating',
'order' => 'queued_at.asc',
'limit' => 1
// Build URL manually to avoid http_build_query encoding issues
$searchUrl = SUPABASE_REST . '/matchmaking_queue'
. '?game_key=eq.' . urlencode($gameKey)
. '&time_control=eq.' . urlencode($timeControl)
. '&status=eq.waiting'
. '&player_id=neq.' . $userId
. '&select=id,player_id,rating'
. '&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])) {
$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