From 8609f03c5a710391018415fae80087b32f422a9a Mon Sep 17 00:00:00 2001 From: Gronod Date: Tue, 19 May 2026 16:41:39 +0100 Subject: [PATCH] fix(webhooks): connect receiver to cache metrics for polling optimization (Phase 5.1) --- server/routes/webhook.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/routes/webhook.js b/server/routes/webhook.js index bd8bd64..0a8ab47 100644 --- a/server/routes/webhook.js +++ b/server/routes/webhook.js @@ -167,6 +167,13 @@ router.post('/sonarr', (req, res) => { logToFile(`[Webhook] Sonarr event received - Type: ${eventType || 'unknown'}, Instance: ${instanceName || 'unknown'}`); logToFile(`[Webhook] Sonarr payload: ${JSON.stringify(req.body)}`); + // Phase 5.1: update webhook metrics for polling optimization + const sonarrInstances = getSonarrInstances(); + const instance = sonarrInstances.find(i => i.name === instanceName); + if (instance) { + cache.updateWebhookMetrics(instance.url); + } + // Phase 2: background cache refresh + SSE broadcast (fire-and-forget) processWebhookEvent('sonarr', eventType).catch(err => { logToFile(`[Webhook] Sonarr background refresh error: ${err.message}`); @@ -196,6 +203,13 @@ router.post('/radarr', (req, res) => { logToFile(`[Webhook] Radarr event received - Type: ${eventType || 'unknown'}, Instance: ${instanceName || 'unknown'}`); logToFile(`[Webhook] Radarr payload: ${JSON.stringify(req.body)}`); + // Phase 5.1: update webhook metrics for polling optimization + const radarrInstances = getRadarrInstances(); + const instance = radarrInstances.find(i => i.name === instanceName); + if (instance) { + cache.updateWebhookMetrics(instance.url); + } + // Phase 2: background cache refresh + SSE broadcast (fire-and-forget) processWebhookEvent('radarr', eventType).catch(err => { logToFile(`[Webhook] Radarr background refresh error: ${err.message}`);