From 86bc6ae90041017acedfba47510153fbef8903f0 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Fri, 10 Jun 2022 03:45:59 +0800 Subject: [PATCH] promotion info do not inject to torrent object --- app/Models/Torrent.php | 11 +---------- app/Repositories/TrackerRepository.php | 8 +++++++- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/Models/Torrent.php b/app/Models/Torrent.php index 12a82b42..30b072aa 100644 --- a/app/Models/Torrent.php +++ b/app/Models/Torrent.php @@ -158,16 +158,7 @@ class Torrent extends NexusModel } $spState = $this->sp_state; $global = self::getGlobalPromotionState(); - $log = sprintf('torrent: %s original sp_state: %s, original global_sp_state: %s', $this->id, $spState, $global); - if ($this->__sticky_promotion) { - //Cover original sp_state - $spState = $this->__sticky_promotion['promotion_type']; - $log .= "[SP_STATE_CHANGE] to __sticky_promotion: $spState]"; - } - if ($this->__ignore_global_sp_state) { - $global = self::PROMOTION_NORMAL; - $log .= "[IGNORE_GLOBAL_SP_STATE], reset to: $global"; - } + $log = sprintf('torrent: %s sp_state: %s, global sp state: %s', $this->id, $spState, $global); if ($global != self::PROMOTION_NORMAL) { $spState = $global; $log .= sprintf(", global != %s, set sp_state to global: %s", self::PROMOTION_NORMAL, $global); diff --git a/app/Repositories/TrackerRepository.php b/app/Repositories/TrackerRepository.php index b1b5facb..488356e3 100644 --- a/app/Repositories/TrackerRepository.php +++ b/app/Repositories/TrackerRepository.php @@ -385,7 +385,7 @@ class TrackerRepository extends BaseRepository if ($torrent->banned == 'yes' && $user->class < Setting::get('authority.seebanned')) { throw new TrackerException("torrent banned"); } - return apply_filter('torrent_detail', $torrent); + return $torrent; } protected function checkPeer(Torrent $torrent, array $queries, User $user): void @@ -677,6 +677,12 @@ class TrackerRepository extends BaseRepository $realDownloaded = max(bcsub($queries['downloaded'], $peer->downloaded), 0); $log .= ", [PEER_EXISTS], realUploaded: $realUploaded, realDownloaded: $realDownloaded"; $spStateReal = $torrent->spStateReal; + $log .= "[SP_STATE_REAL]: $spStateReal"; + $promotionInfo = apply_filter('torrent_promotion', $torrent->toArray()); + if ($promotionInfo) { + $spStateReal = $promotionInfo['sp_state']; + $log .= "[CHANGE_SP_STATE_BY_FILTER_TORRENT_PROMOTION]: $spStateReal"; + } $uploaderRatio = Setting::get('torrent.uploaderdouble'); $log .= ", spStateReal: $spStateReal, uploaderRatio: $uploaderRatio"; if ($torrent->owner == $user->id) {