Commit ea0e40bf authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: Swiss API GET requests fail with content-type header + bot names not showing

1. ApiProxy was sending Content-Type: application/json on GET requests
   which the Swiss API rejects ("Body cannot be empty when content-type
   is set to application/json"). Now only sends Content-Type for
   POST/PATCH/PUT methods.

2. Players tab now reads bot name/rating from bot_metadata JSONB
   instead of non-existent player_name/rating columns.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 4fb214bb
...@@ -15,7 +15,11 @@ class ApiProxy ...@@ -15,7 +15,11 @@ class ApiProxy
public static function swiss(string $method, string $path, ?array $body = null, ?string $token = null): array public static function swiss(string $method, string $path, ?array $body = null, ?string $token = null): array
{ {
$headers = ['Content-Type: application/json']; $headers = [];
$upperMethod = strtoupper($method);
if ($body !== null || in_array($upperMethod, ['POST', 'PATCH', 'PUT'])) {
$headers[] = 'Content-Type: application/json';
}
$authToken = $token ?? self::getSwissToken(); $authToken = $token ?? self::getSwissToken();
if ($authToken) { if ($authToken) {
$headers[] = 'Authorization: Bearer ' . $authToken; $headers[] = 'Authorization: Bearer ' . $authToken;
......
...@@ -235,13 +235,19 @@ $tabs['arbiter'] = 'أدوات الحكم'; ...@@ -235,13 +235,19 @@ $tabs['arbiter'] = 'أدوات الحكم';
</thead> </thead>
<tbody> <tbody>
<?php foreach ($players as $i => $player): ?> <?php foreach ($players as $i => $player): ?>
<?php
$meta = $player['bot_metadata'] ?? null;
if (is_string($meta)) $meta = json_decode($meta, true);
$playerName = $meta['name'] ?? $player['player_name'] ?? $player['player_id'];
$playerRating = $meta['rating'] ?? $player['rating'] ?? '-';
?>
<tr> <tr>
<td><?= $i + 1 ?></td> <td><?= $i + 1 ?></td>
<td class="font-medium"> <td class="font-medium">
<?= View::e($player['player_name'] ?? $player['player_id']) ?> <?= View::e($playerName) ?>
<?php if (!empty($player['is_bot'])): ?><span class="badge badge-ghost" style="font-size:10px;margin-right:4px;">🤖</span><?php endif; ?> <?php if (!empty($player['is_bot'])): ?><span class="badge badge-ghost" style="font-size:10px;margin-right:4px;">🤖</span><?php endif; ?>
</td> </td>
<td class="tabular-nums"><?= $player['rating'] ?? 1500 ?></td> <td class="tabular-nums"><?= $playerRating ?></td>
<td class="text-xs text-muted"><?= $player['registered_at'] ? date('Y/m/d H:i', strtotime($player['registered_at'])) : '-' ?></td> <td class="text-xs text-muted"><?= $player['registered_at'] ? date('Y/m/d H:i', strtotime($player['registered_at'])) : '-' ?></td>
<td> <td>
<?php if (($player['status'] ?? '') === 'withdrawn'): ?> <?php if (($player['status'] ?? '') === 'withdrawn'): ?>
......
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