From b10bb1f2e151ee6ea63103dbec0b87f5089cc815 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Thu, 13 Feb 2025 11:04:04 +0100 Subject: [PATCH] prevent chatting in event far in the future --- modules/api/src/main/ChatFreshness.scala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/api/src/main/ChatFreshness.scala b/modules/api/src/main/ChatFreshness.scala index 74271eb192f7e..2df612cf94049 100644 --- a/modules/api/src/main/ChatFreshness.scala +++ b/modules/api/src/main/ChatFreshness.scala @@ -13,9 +13,11 @@ final class ChatFreshness(tourCache: TournamentCache, swissCache: SwissCache)(us case _ => fuTrue def of(tour: Tournament) = - tour.finishedSinceSeconds.forall: - _ < (tour.nbPlayers + 120) * 30 + tour.finishedSinceSeconds match + case Some(finishedSinceSeconds) => finishedSinceSeconds < (tour.nbPlayers + 120) * 30 + case None => tour.startsAt.isBefore(nowInstant.plusWeeks(1)) def of(swiss: Swiss) = - swiss.finishedSinceSeconds.forall: - _ < (swiss.nbPlayers + 60) * 60 + swiss.finishedSinceSeconds match + case Some(finishedSinceSeconds) => finishedSinceSeconds < (swiss.nbPlayers + 60) * 60 + case None => swiss.startsAt.isBefore(nowInstant.plusWeeks(1))