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}`);