From 4135e70b629d4cbfe3f32c1ddf33cd5f6d096208 Mon Sep 17 00:00:00 2001 From: ghost Date: Thu, 14 Sep 2023 20:33:43 +0300 Subject: [PATCH] add approved only content import options --- example/environment/env.example.php | 15 +++++++++------ src/crontab/import/feed.php | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/example/environment/env.example.php b/example/environment/env.example.php index b2efba4..602010a 100644 --- a/example/environment/env.example.php +++ b/example/environment/env.example.php @@ -140,9 +140,12 @@ define('API_EXPORT_MAGNET_VIEWS_ENABLED', true); // depends of API_EXPORT_EN /// Import define('API_IMPORT_ENABLED', true); -define('API_IMPORT_USERS_ENABLED', true); // depends of API_IMPORT_ENABLED -define('API_IMPORT_MAGNETS_ENABLED', true); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED -define('API_IMPORT_MAGNET_DOWNLOADS_ENABLED', true); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED, API_IMPORT_MAGNETS_ENABLED -define('API_IMPORT_MAGNET_COMMENTS_ENABLED', true); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED, API_IMPORT_MAGNETS_ENABLED -define('API_IMPORT_MAGNET_STARS_ENABLED', true); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED, API_IMPORT_MAGNETS_ENABLED -define('API_IMPORT_MAGNET_VIEWS_ENABLED', true); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED, API_IMPORT_MAGNETS_ENABLED \ No newline at end of file +define('API_IMPORT_USERS_ENABLED', true); // depends of API_IMPORT_ENABLED +define('API_IMPORT_USERS_APPROVED_ONLY', false); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED +define('API_IMPORT_MAGNETS_ENABLED', true); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED +define('API_IMPORT_MAGNETS_APPROVED_ONLY', false); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED, API_IMPORT_MAGNETS_ENABLED +define('API_IMPORT_MAGNET_DOWNLOADS_ENABLED', true); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED, API_IMPORT_MAGNETS_ENABLED +define('API_IMPORT_MAGNET_COMMENTS_ENABLED', true); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED, API_IMPORT_MAGNETS_ENABLED +define('API_IMPORT_MAGNET_COMMENTS_APPROVED_ONLY', false); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED, API_IMPORT_MAGNETS_ENABLED, API_IMPORT_MAGNET_COMMENTS_ENABLED +define('API_IMPORT_MAGNET_STARS_ENABLED', true); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED, API_IMPORT_MAGNETS_ENABLED +define('API_IMPORT_MAGNET_VIEWS_ENABLED', true); // depends of API_IMPORT_ENABLED, API_IMPORT_USERS_ENABLED, API_IMPORT_MAGNETS_ENABLED \ No newline at end of file diff --git a/src/crontab/import/feed.php b/src/crontab/import/feed.php index 2344713..3682c93 100644 --- a/src/crontab/import/feed.php +++ b/src/crontab/import/feed.php @@ -69,6 +69,12 @@ try continue; } + // Skip import on user approved required + if (API_IMPORT_USERS_APPROVED_ONLY && !$remoteUser->approved) + { + continue; + } + // Yggdrasil connections only else if (!preg_match(YGGDRASIL_HOST_REGEX, $remoteUser->address)) { @@ -170,6 +176,12 @@ try continue; } + // Skip import on magnet approved required + if (API_IMPORT_MAGNETS_APPROVED_ONLY && !$remoteMagnet->approved) + { + continue; + } + // Add new magnet if not exist by timestamp added for this user if (!$localMagnet = $db->findMagnet($aliasUserId[$remoteMagnet->userId], $remoteMagnet->timeAdded)) { @@ -395,6 +407,12 @@ try continue; } + // Skip import on magnet comment approved required + if (API_IMPORT_MAGNET_COMMENTS_APPROVED_ONLY && !$remoteMagnetComment->approved) + { + continue; + } + // Add new magnet comment if not exist by timestamp added for this user if (!$db->findMagnetComment($aliasMagnetId[$remoteMagnetComment->magnetId], $aliasUserId[$remoteMagnetComment->userId],