From 73f353594c132e3aace7c7735c2f82f9dc6acd37 Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 15 Sep 2023 04:06:54 +0300 Subject: [PATCH] send push on addMagnetDownload success only --- src/public/download.php | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/public/download.php b/src/public/download.php index af46593..ce0f703 100644 --- a/src/public/download.php +++ b/src/public/download.php @@ -63,29 +63,30 @@ else if (is_null($user->public)) else { // Register magnet download - $magnetDownloadId = $db->addMagnetDownload($magnet->magnetId, $user->userId, time()); - - // Push event to other nodes - if (API_EXPORT_ENABLED && - API_EXPORT_PUSH_ENABLED && - API_EXPORT_USERS_ENABLED && - API_EXPORT_MAGNETS_ENABLED && - API_EXPORT_MAGNET_DOWNLOADS_ENABLED) + if ($magnetDownloadId = $db->addMagnetDownload($magnet->magnetId, $user->userId, time())) { - if (!$memoryApiExportPush = $memory->get('api.export.push')) - { - $memoryApiExportPush = []; - } + // Push event to other nodes + if (API_EXPORT_ENABLED && + API_EXPORT_PUSH_ENABLED && + API_EXPORT_USERS_ENABLED && + API_EXPORT_MAGNETS_ENABLED && + API_EXPORT_MAGNET_DOWNLOADS_ENABLED) + { + if (!$memoryApiExportPush = $memory->get('api.export.push')) + { + $memoryApiExportPush = []; + } - $memoryApiExportPush[] = (object) - [ - 'time' => time(), - 'userId' => $user->userId, - 'magnetId' => $magnet->magnetId, - 'magnetDownloadId' => $magnetDownloadId - ]; + $memoryApiExportPush[] = (object) + [ + 'time' => time(), + 'userId' => $user->userId, + 'magnetId' => $magnet->magnetId, + 'magnetDownloadId' => $magnetDownloadId + ]; - $memory->set('api.export.push', $memoryApiExportPush, 3600); + $memory->set('api.export.push', $memoryApiExportPush, 3600); + } } // Build magnet link