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;