Extend download webhook to all grabs, not just upgrades; add DOWNLOAD_WEBHOOK_ENABLED toggle
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?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.
|
||||
header('Content-Type: application/json');
|
||||
require_once dirname(__DIR__) . '/include/config.php';
|
||||
@@ -20,14 +20,20 @@ if (!$payload) {
|
||||
$event = $payload['eventType'] ?? '';
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Sonarr/Radarr/Lidarr fire eventType "Download" with isUpgrade=true for upgrades.
|
||||
// A plain Download (no upgrade) is not our concern — the original quality is fine.
|
||||
$is_upgrade = $payload['isUpgrade'] ?? false;
|
||||
if ($event !== 'Download' || !$is_upgrade) {
|
||||
$vars = vv_conf_vars();
|
||||
$enabled = strtolower($vars['DOWNLOAD_WEBHOOK_ENABLED'] ?? 'true') !== 'false';
|
||||
if (!$enabled) {
|
||||
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]);
|
||||
exit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user