Extend download webhook to all grabs, not just upgrades; add DOWNLOAD_WEBHOOK_ENABLED toggle
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
// Receives Sonarr/Radarr/Lidarr OnUpgrade events. Fires upgrade_webhook_handler.sh
|
// Receives Sonarr/Radarr/Lidarr Download events. Fires upgrade_webhook_handler.sh
|
||||||
// in the background and returns 200 immediately — arr does not wait on the push.
|
// in the background and returns 200 immediately — arr does not wait on the push.
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
require_once dirname(__DIR__) . '/include/config.php';
|
require_once dirname(__DIR__) . '/include/config.php';
|
||||||
@@ -20,14 +20,20 @@ if (!$payload) {
|
|||||||
$event = $payload['eventType'] ?? '';
|
$event = $payload['eventType'] ?? '';
|
||||||
|
|
||||||
if ($event === 'Test') {
|
if ($event === 'Test') {
|
||||||
echo json_encode(['ok' => true, 'message' => 'Webhook connected — configure On Upgrade to use this URL']);
|
echo json_encode(['ok' => true, 'message' => 'Webhook connected — configure On Download to use this URL']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sonarr/Radarr/Lidarr fire eventType "Download" with isUpgrade=true for upgrades.
|
$vars = vv_conf_vars();
|
||||||
// A plain Download (no upgrade) is not our concern — the original quality is fine.
|
$enabled = strtolower($vars['DOWNLOAD_WEBHOOK_ENABLED'] ?? 'true') !== 'false';
|
||||||
$is_upgrade = $payload['isUpgrade'] ?? false;
|
if (!$enabled) {
|
||||||
if ($event !== 'Download' || !$is_upgrade) {
|
echo json_encode(['ok' => true, 'skipped' => 'DOWNLOAD_WEBHOOK_ENABLED=false']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fire on any Download event — new grabs and upgrades both need immediate propagation
|
||||||
|
// so remote nodes don't search for something we already have.
|
||||||
|
if ($event !== 'Download') {
|
||||||
echo json_encode(['ok' => true, 'skipped' => $event]);
|
echo json_encode(['ok' => true, 'skipped' => $event]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user