mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-14 23:26:15 -05:00
Allow TO's to read chats after tournament has finalized
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user