From 8f2ea1658698498029ee67b1b99afe3a3fc4c0cb Mon Sep 17 00:00:00 2001 From: retardgerman <78982850+retardgerman@users.noreply.github.com> Date: Tue, 12 May 2026 12:35:31 +0200 Subject: [PATCH] fix(dedup): extend TTL to ~5 years so upgrades never re-notify or re-appear in roundup Previously sentNotifications expired after 7 days and roundup-first-seen after 14 days. A Sonarr/Radarr quality upgrade landing after those windows was treated as a brand-new item. Both windows are now ~5 years, which is effectively permanent for any realistic install lifetime. Also fixes the [DUPLICATE CHECK] log line that was checking debouncedSenders with raw SeriesId instead of the stable seriesKey, causing it to always report `has debouncer: false` for keyed series. --- bot/roundupFirstSeen.js | 7 +++---- jellyfinWebhook.js | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/bot/roundupFirstSeen.js b/bot/roundupFirstSeen.js index 7a57eab..9f49382 100644 --- a/bot/roundupFirstSeen.js +++ b/bot/roundupFirstSeen.js @@ -1,9 +1,8 @@ import { PersistentMap } from "../utils/persistentMap.js"; -// Wider than the 7-day roundup window so an item filtered out one week is -// still remembered the following week (avoids it re-appearing as "new" if -// Sonarr does a second upgrade just past the 7-day mark). -const TTL_MS = 14 * 24 * 60 * 60 * 1000; +// Items already seen should never re-appear as "new" regardless of how many +// Sonarr/Radarr quality upgrades happen. ~5 years is effectively permanent. +const TTL_MS = 5 * 365 * 24 * 60 * 60 * 1000; const map = new PersistentMap("roundup-first-seen", TTL_MS, { validateValue: (v) => v && typeof v.firstSeenAt === "number", diff --git a/jellyfinWebhook.js b/jellyfinWebhook.js index fe5200f..af9c0ab 100644 --- a/jellyfinWebhook.js +++ b/jellyfinWebhook.js @@ -25,7 +25,7 @@ const debouncedSenders = new Map(); // re-notifies anything in the recently-added window via the next poll/WS reconnect). const sentNotifications = new PersistentMap( "sent-notifications", - 7 * 24 * 60 * 60 * 1000, // 7 days — survive Sonarr/Radarr upgrade cycles + 5 * 365 * 24 * 60 * 60 * 1000, // ~5 years — items already in the library never re-notify { validateValue: (v) => v && typeof v.level === "number" } ); @@ -1003,7 +1003,7 @@ export async function handleJellyfinWebhook(req, res, client, pendingRequests, o `[DUPLICATE CHECK] ${data.ItemType} "${ data.Name }" - SeriesId: ${SeriesId}, sentLevel: ${sentLevel}, currentLevel: ${currentLevel}, has debouncer: ${debouncedSenders.has( - SeriesId + seriesKey )}` );