Skip to content

Commit

Permalink
prevent chatting in event far in the future
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Feb 13, 2025
1 parent 3f75795 commit b10bb1f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions modules/api/src/main/ChatFreshness.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))

0 comments on commit b10bb1f

Please sign in to comment.