Keep pregame lobby chat open for an hour after the game ends
The chat used to disappear the moment a session left CREATED status.
Sessions now record a finishedAt timestamp when they're won or lost,
and the lobby (with chat) stays reachable via /game/{session} for an
hour afterward instead of immediately redirecting to the win/lose
feedback page. The lobby template shows a distinct "game finished"
header with a link to that feedback page during this window.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,7 @@ final class GameDashboardService
|
||||
{
|
||||
private const READY_TIMEOUT_SECONDS = 60;
|
||||
private const LOBBY_MESSAGE_MAX_LENGTH = 500;
|
||||
private const LOBBY_CHAT_GRACE_PERIOD_SECONDS = 3600;
|
||||
|
||||
public function __construct(
|
||||
private readonly GameRepository $gameRepository,
|
||||
@@ -302,9 +303,32 @@ final class GameDashboardService
|
||||
return $this->lobbyMessageRepository->findForSession($session);
|
||||
}
|
||||
|
||||
/**
|
||||
* The lobby chat is open while a session is still gathering players, and stays
|
||||
* open for a grace period after the game ends so players can wrap up the
|
||||
* conversation before it disappears.
|
||||
*/
|
||||
public function isLobbyChatOpen(Session $session): bool
|
||||
{
|
||||
if ($session->getStatus() === SessionStatus::CREATED) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!in_array($session->getStatus(), [SessionStatus::WON, SessionStatus::LOST], true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$finishedAt = $session->getFinishedAt();
|
||||
if ($finishedAt === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (new \DateTime())->getTimestamp() - $finishedAt->getTimestamp() < self::LOBBY_CHAT_GRACE_PERIOD_SECONDS;
|
||||
}
|
||||
|
||||
public function postLobbyMessage(Session $session, User $user, string $content): ?LobbyMessage
|
||||
{
|
||||
if ($session->getStatus() !== SessionStatus::CREATED) {
|
||||
if (!$this->isLobbyChatOpen($session)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user