promotion info do not inject to torrent object

This commit is contained in:
xiaomlove
2022-06-10 03:45:59 +08:00
parent 35f78b4b77
commit 86bc6ae900
2 changed files with 8 additions and 11 deletions

View File

@@ -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);

View File

@@ -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) {