let revoke_delegate_data = if status.map_or(true, |x| x == "started") && delegate_itself
{
let csrf = Uuid::new_v4();
let mut cache = data.cache_revoke_delegation_game.lock().await;
cache.insert(
csrf,
(
gameuid.clone(),
player_name.to_lowercase(),
user.to_lowercase(),
),
std::time::Duration::from_secs(data.cache_duration_sec),
);
Some(JoinLeaveData { csrf })
} else if status.map_or(true, |x| x == "started") && player_itself {
if let Some(ref delegate_name) = delegate_name {
let csrf = Uuid::new_v4();
let mut cache = data.cache_revoke_delegation_game.lock().await;
cache.insert(
csrf,
(
gameuid.clone(),
user.to_lowercase(),
delegate_name.to_lowercase(),
),
std::time::Duration::from_secs(data.cache_duration_sec),
);
Some(JoinLeaveData { csrf })
} else {
None
}
} else {
None
};