fix(webhooks): connect receiver to cache metrics for polling optimization (Phase 5.1)
This commit is contained in:
@@ -167,6 +167,13 @@ router.post('/sonarr', (req, res) => {
|
|||||||
logToFile(`[Webhook] Sonarr event received - Type: ${eventType || 'unknown'}, Instance: ${instanceName || 'unknown'}`);
|
logToFile(`[Webhook] Sonarr event received - Type: ${eventType || 'unknown'}, Instance: ${instanceName || 'unknown'}`);
|
||||||
logToFile(`[Webhook] Sonarr payload: ${JSON.stringify(req.body)}`);
|
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)
|
// Phase 2: background cache refresh + SSE broadcast (fire-and-forget)
|
||||||
processWebhookEvent('sonarr', eventType).catch(err => {
|
processWebhookEvent('sonarr', eventType).catch(err => {
|
||||||
logToFile(`[Webhook] Sonarr background refresh error: ${err.message}`);
|
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 event received - Type: ${eventType || 'unknown'}, Instance: ${instanceName || 'unknown'}`);
|
||||||
logToFile(`[Webhook] Radarr payload: ${JSON.stringify(req.body)}`);
|
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)
|
// Phase 2: background cache refresh + SSE broadcast (fire-and-forget)
|
||||||
processWebhookEvent('radarr', eventType).catch(err => {
|
processWebhookEvent('radarr', eventType).catch(err => {
|
||||||
logToFile(`[Webhook] Radarr background refresh error: ${err.message}`);
|
logToFile(`[Webhook] Radarr background refresh error: ${err.message}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user