Allow TO's to read chats after tournament has finalized

This commit is contained in:
Kalle
2026-04-19 10:29:54 +03:00
parent 793ebfe4a4
commit 3d7f24d2ee
2 changed files with 12 additions and 9 deletions

View File

@@ -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 {

View File

@@ -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;