Commit b789888e authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix(reactions): backgammon players can send reactions in online games

isMatchParticipant() knew only ludo and domino matches, so every reaction
poll in an online backgammon game answered 403 and nothing reached the
opponent. Backgammon seats come from players or the colour columns.
Co-Authored-By: 's avatarClaude Opus 5.5 <noreply@anthropic.com>
parent 0fa3571d
......@@ -214,13 +214,17 @@ function isMatchParticipant($sdb, string $gameKey, string $matchId, string $user
}
$table = [
'ludo' => 'ludo_matches',
'domino' => 'domino_matches',
'ludo' => 'ludo_matches',
'domino' => 'domino_matches',
'backgammon' => 'backgammon_matches',
][$gameKey] ?? null;
if (!$table) return false;
$rows = $sdb->get($table, ['id' => 'eq.' . $matchId, 'select' => 'players', 'limit' => 1]);
// Backgammon rows may seat players by colour instead of (or as well as) the list.
$select = $gameKey === 'backgammon' ? 'players,white_player_id,black_player_id' : 'players';
$rows = $sdb->get($table, ['id' => 'eq.' . $matchId, 'select' => $select, 'limit' => 1]);
if (!is_array($rows) || empty($rows) || isset($rows['error'])) return false;
if (($rows[0]['white_player_id'] ?? null) === $userId || ($rows[0]['black_player_id'] ?? null) === $userId) return true;
$players = $rows[0]['players'] ?? [];
if (is_string($players)) $players = json_decode($players, true) ?: [];
......
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