From 105ea911c96cd444dc6dd5d1178aa909d5f8759a Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Mon, 20 Nov 2023 00:16:54 +0700 Subject: [PATCH] Fixed announcer-list issue (#1131) * Fixed announcer-list issue * Update CHANGELOG.md --- CHANGELOG.md | 2 +- src/Legacy/Torrent.php | 30 +++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 335074090..1c446dfd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ **Merged pull requests:** -- Fixed announcer-list issue [\#1129](https://github.com/torrentpier/torrentpier/pull/1129), [\#1130](https://github.com/torrentpier/torrentpier/pull/1130) ([belomaxorka](https://github.com/belomaxorka)) +- Fixed announcer-list issue [\#1129](https://github.com/torrentpier/torrentpier/pull/1129), [\#1130](https://github.com/torrentpier/torrentpier/pull/1130), [\#1131](https://github.com/torrentpier/torrentpier/pull/1131) ([belomaxorka](https://github.com/belomaxorka)) - Removed client column from bb_bt_tracker table [\#1128](https://github.com/torrentpier/torrentpier/pull/1128) ([belomaxorka](https://github.com/belomaxorka)) - Removed one-time used variables [\#1120](https://github.com/torrentpier/torrentpier/pull/1120) ([belomaxorka](https://github.com/belomaxorka)) - Don't create empty announce-list dict, if ann_urls are empty [\#1119](https://github.com/torrentpier/torrentpier/pull/1119) ([kovalensky](https://github.com/kovalensky)) diff --git a/src/Legacy/Torrent.php b/src/Legacy/Torrent.php index 0f4fbd39b..0d20eb20f 100644 --- a/src/Legacy/Torrent.php +++ b/src/Legacy/Torrent.php @@ -574,15 +574,6 @@ class Torrent } unset($additional_announce_urls); - // Adding tracker announcer to announce-list - if ($bb_cfg['bt_replace_ann_url']) { - // Adding tracker announcer as main announcer (At start) - array_unshift($tor['announce-list'], [$announce_url]); - } else { - // Adding tracker announcer (At end) - $tor['announce-list'] = array_merge($tor['announce-list'], [[$announce_url]]); - } - // Adding additional announce urls (If present) if (!empty($announce_urls_add)) { $tor['announce-list'] = array_merge($tor['announce-list'], $announce_urls_add); @@ -595,6 +586,27 @@ class Torrent } } + // Adding tracker announcer to announce-list + if (!empty($tor['announce-list'])) { + if ($bb_cfg['bt_replace_ann_url']) { + // Adding tracker announcer as main announcer (At start) + array_unshift($tor['announce-list'], [$announce_url]); + } else { + // Adding torrent announcer (At start) + array_unshift($tor['announce-list'], [$tor['announce']]); + + // Adding tracker announcer (At end) + if ($tor['announce'] != $announce_url) { + $tor['announce-list'] = array_merge($tor['announce-list'], [[$announce_url]]); + } + } + } + + // Remove announce-list if empty + if (empty($tor['announce-list'])) { + unset($tor['announce-list']); + } + // Add publisher & topic url $publisher_name = $bb_cfg['server_name']; $publisher_url = make_url(TOPIC_URL . $topic_id);