feat: add admin award winner command #23

Merged
remhelper merged 4 commits from feature/admin-award-winner into main 2026-03-06 05:49:50 +00:00
Showing only changes of commit da49712a79 - Show all commits

View File

@@ -835,11 +835,24 @@ impl Server {
drop(matches_guard);
let the_match = found_match.read().await;
if winner_username != the_match.player1.to_string()
&& winner_username != the_match.player2.to_string()
{
// Validate that the declared winner is actually one of the players in this match
let clients_guard = self.clients.read().await;
let player1_client = clients_guard.get(&the_match.player1);
let player2_client = clients_guard.get(&the_match.player2);
// If we cannot resolve both players, or the winner username doesn't match either, reject
if let (Some(p1_arc), Some(p2_arc)) = (player1_client, player2_client) {
let p1 = p1_arc.read().await;
let p2 = p2_arc.read().await;
if winner_username != p1.username && winner_username != p2.username {
return Err(anyhow!("ERROR:INVALID:AWARD"));
}
} else {
return Err(anyhow!("ERROR:INVALID:AWARD"));
}
drop(clients_guard);
self.matches.write().await.remove(&match_id);