From 3d7f24d2eef3ee10e3ed7695c1e259efc61c0e9a Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 19 Apr 2026 10:29:54 +0300 Subject: [PATCH] =?UTF-8?q?Allow=20TO's=20to=20read=20chats=20after=C2=A0t?= =?UTF-8?q?ournament=20has=20finalized?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/features/chat/chat-utils.ts | 4 +++- .../loaders/to.$id.matches.$mid.server.ts | 17 +++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/features/chat/chat-utils.ts b/app/features/chat/chat-utils.ts index 9cc422422..316989bb8 100644 --- a/app/features/chat/chat-utils.ts +++ b/app/features/chat/chat-utils.ts @@ -3,8 +3,10 @@ import type { ChatMessage } from "./chat-types"; const STAFF_EXTRA_DAYS = 7; +/** Should a chat room be still accessible via chat code. */ export function chatAccessible(args: { - isStaff: boolean; + /** Is the user site staff? Allows them to see the chat code for extra days. */ + isStaff?: boolean; expiresAfterDays: number; comparedTo: Date; }): boolean { diff --git a/app/features/tournament-bracket/loaders/to.$id.matches.$mid.server.ts b/app/features/tournament-bracket/loaders/to.$id.matches.$mid.server.ts index 2feeb52ef..3258512fe 100644 --- a/app/features/tournament-bracket/loaders/to.$id.matches.$mid.server.ts +++ b/app/features/tournament-bracket/loaders/to.$id.matches.$mid.server.ts @@ -165,14 +165,15 @@ export const loader = async ({ params }: LoaderFunctionArgs) => { tournament.isOrganizerOrStreamer(user) || match.players.some((p) => p.id === user?.id); - const isStaff = user?.roles.includes("STAFF") ?? false; - const chatCodeExpired = tournament.ctx.isFinalized - ? true - : !chatAccessible({ - isStaff, - expiresAfterDays: 90, - comparedTo: tournament.ctx.startTime, - }); + const isSiteStaff = user?.roles.includes("STAFF") ?? false; + const isTournamentStaff = tournament.isOrganizer(user); + const chatCodeExpired = + tournament.ctx.isFinalized && !isSiteStaff && !isTournamentStaff + ? true + : !chatAccessible({ + expiresAfterDays: tournament.isLeagueDivision ? 30 : 7, + comparedTo: tournament.ctx.startTime, + }); const visibleChatCode = shouldSeeChat && !chatCodeExpired ? match.chatCode : undefined;