From 5698defa4f472d666c68a75c206c3d5b99b8c91d Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 23 Mar 2025 11:46:44 +0200 Subject: [PATCH] Prevent new season notification from refiring --- app/routines/notifySeasonStart.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/routines/notifySeasonStart.ts b/app/routines/notifySeasonStart.ts index 09c5323c9..fba99de1e 100644 --- a/app/routines/notifySeasonStart.ts +++ b/app/routines/notifySeasonStart.ts @@ -1,3 +1,4 @@ +import { add } from "date-fns"; import { currentSeason } from "../features/mmr/season"; import { userSkills } from "../features/mmr/tiered.server"; import * as NotificationRepository from "../features/notifications/NotificationRepository.server"; @@ -9,7 +10,10 @@ export const NotifySeasonStartRoutine = new Routine({ func: async () => { const season = currentSeason(new Date()); - if (!season) return; + // old notifications get deleted after 14 days, make sure we don't send the same notification twice + if (!season || add(season.starts, { days: 7 }) < new Date()) { + return; + } const seasonNotifications = await NotificationRepository.findAllByType("SEASON_STARTED");