From ed0467f98e4c8650cde08176404a49793ff141c7 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sat, 25 Apr 2026 21:15:17 +0300 Subject: [PATCH] Fix tournament chats expiring too early In round robin, all matches are set to have both participants at the start. If the bracket is larger e.g. 5 rounds then later rounds might have chat disappearing before teams get a chance to play it. Closes #3005 --- app/features/chat/ChatSystemMessage.server.ts | 4 ++++ .../loaders/to.$id.matches.$mid.server.ts | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/features/chat/ChatSystemMessage.server.ts b/app/features/chat/ChatSystemMessage.server.ts index 18cd53bf1..69da91c06 100644 --- a/app/features/chat/ChatSystemMessage.server.ts +++ b/app/features/chat/ChatSystemMessage.server.ts @@ -141,6 +141,10 @@ export async function setMetadata(args: SetMetadataArgs) { args.participantUserIds, ); + logger.debug( + `Setting chat room metadata for ${args.chatCode} (participants: ${participantsKey})`, + ); + return void fetch(process.env.SKALOP_SYSTEM_MESSAGE_URL, { method: "POST", body: JSON.stringify({ 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 06f8aed54..8ace38f65 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 @@ -6,6 +6,7 @@ import { chatAccessible } from "~/features/chat/chat-utils"; import * as TournamentRepository from "~/features/tournament/TournamentRepository.server"; import * as TournamentTeamRepository from "~/features/tournament/TournamentTeamRepository.server"; import * as UserRepository from "~/features/user-page/UserRepository.server"; +import { Status } from "~/modules/brackets-model"; import { cache, IN_MILLISECONDS, ttl } from "~/utils/cache.server"; import { IS_E2E_TEST_RUN } from "~/utils/e2e"; import { logger } from "~/utils/logger"; @@ -148,7 +149,8 @@ export const loader = async ({ params }: LoaderFunctionArgs) => { match.chatCode && !matchIsOver && match.opponentOne?.id && - match.opponentTwo?.id + match.opponentTwo?.id && + match.status > Status.Locked ) { // only add global chat for active roster (or all if not yet set i.e. first match) // if roster changed mid-set the subs can still see the chat on the match page @@ -180,7 +182,7 @@ export const loader = async ({ params }: LoaderFunctionArgs) => { }); } - const shouldSeeChat = + const hasPermsToSeeChat = tournament.isOrganizerOrStreamer(user) || match.players.some((p) => p.id === user?.id); @@ -195,10 +197,10 @@ export const loader = async ({ params }: LoaderFunctionArgs) => { }); const visibleChatCode = - shouldSeeChat && !chatCodeExpired ? match.chatCode : undefined; + hasPermsToSeeChat && !chatCodeExpired ? match.chatCode : undefined; return { - match: shouldSeeChat ? match : { ...match, chatCode: undefined }, + match: hasPermsToSeeChat ? match : { ...match, chatCode: undefined }, results, mapList, matchIsOver,