From 5c47ce3cc6bb4d402fe3bc82abdaf975af04f458 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Mon, 28 Sep 2026 21:05:44 +0300 Subject: [PATCH] Mark tournament team chats as inactive once the tournament is finalized --- .../chat/ChatRoomResolver.server.test.ts | 20 +++++++++++++++++++ app/features/chat/ChatRoomResolver.server.ts | 1 + .../TournamentTeamRepository.server.ts | 2 ++ ...finalized-tournament-team-chat-inactive.md | 5 +++++ 4 files changed, 28 insertions(+) create mode 100644 changelog/2026-09-28-finalized-tournament-team-chat-inactive.md diff --git a/app/features/chat/ChatRoomResolver.server.test.ts b/app/features/chat/ChatRoomResolver.server.test.ts index 565c8fc3b..e379aa3af 100644 --- a/app/features/chat/ChatRoomResolver.server.test.ts +++ b/app/features/chat/ChatRoomResolver.server.test.ts @@ -196,6 +196,26 @@ describe("ChatRoomResolver.resolve", () => { expect(room.permissions.OBSERVE).toContain(authorId); }); + test("marks a TOURNAMENT_TEAM room inactive once the tournament is finalized", async () => { + const tournament = await TournamentFactory.create({ + authorId: users.id(2), + }); + const team = await TournamentTeamFactory.create( + { + tournamentId: tournament.id, + memberUserIds: [users.id(3), users.id(4)], + }, + { isLooking: true }, + ); + const chatRoomId = await teamChatRoomId(team.id); + + expect((await resolveOrThrow(chatRoomId)).inactive).toBe(false); + + await TournamentRepository.finalizeWithoutSummary(tournament.id); + + expect((await resolveOrThrow(chatRoomId)).inactive).toBe(true); + }); + test("resolves a SCRIM room to the post's users plus the accepted request's users", async () => { const { chatRoomId, postUserIds, requestUserIds, startsAt } = await setupAcceptedScrim(); diff --git a/app/features/chat/ChatRoomResolver.server.ts b/app/features/chat/ChatRoomResolver.server.ts index dabc76210..04c667253 100644 --- a/app/features/chat/ChatRoomResolver.server.ts +++ b/app/features/chat/ChatRoomResolver.server.ts @@ -224,6 +224,7 @@ async function resolveTournamentTeamRooms( participantUserIds: owner.members.map((member) => member.userId), observerUserIds: organizers.get(owner.tournamentId)?.ORGANIZE ?? [], labelByUserId: organizerLabels(organizers.get(owner.tournamentId)), + inactive: Boolean(owner.isFinalized), })); } diff --git a/app/features/tournament/TournamentTeamRepository.server.ts b/app/features/tournament/TournamentTeamRepository.server.ts index af24be800..3a6379a67 100644 --- a/app/features/tournament/TournamentTeamRepository.server.ts +++ b/app/features/tournament/TournamentTeamRepository.server.ts @@ -23,6 +23,7 @@ export async function findAllByChatRoomIds(chatRoomIds: number[]) { return db .selectFrom("TournamentTeam") + .innerJoin("Tournament", "Tournament.id", "TournamentTeam.tournamentId") .innerJoin( "CalendarEvent", "CalendarEvent.tournamentId", @@ -32,6 +33,7 @@ export async function findAllByChatRoomIds(chatRoomIds: number[]) { "TournamentTeam.chatRoomId", "TournamentTeam.name", "TournamentTeam.tournamentId", + "Tournament.isFinalized", "CalendarEvent.name as tournamentName", tournamentLogoWithDefault(eb).as("logoUrl"), jsonArrayFrom( diff --git a/changelog/2026-09-28-finalized-tournament-team-chat-inactive.md b/changelog/2026-09-28-finalized-tournament-team-chat-inactive.md new file mode 100644 index 000000000..12cd9bd7a --- /dev/null +++ b/changelog/2026-09-28-finalized-tournament-team-chat-inactive.md @@ -0,0 +1,5 @@ +--- +navItem: medal +type: bug +--- +Fix tournament team chats staying active after the tournament was finalized