fix torrent searchbox id

This commit is contained in:
xiaomlove
2022-11-05 01:39:20 +08:00
parent 7d63a0586a
commit aae99b0df1
6 changed files with 36 additions and 7 deletions

View File

@@ -62,7 +62,12 @@ class HitAndRun extends NexusModel
if ($this->status != self::STATUS_INSPECTING) { if ($this->status != self::STATUS_INSPECTING) {
return '---'; return '---';
} }
$inspectTime = HitAndRun::getConfig('inspect_time', $this->torrent->basic_category->mode); $searchBoxId = $this->torrent->basic_category->mode ?? 0;
if ($searchBoxId == 0) {
do_log(sprintf('[INVALID_CATEGORY], Torrent: %s', $this->torrent_id), 'error');
return '---';
}
$inspectTime = HitAndRun::getConfig('inspect_time', $searchBoxId);
$diffInSeconds = Carbon::now()->diffInSeconds($this->snatch->completedat->addHours($inspectTime)); $diffInSeconds = Carbon::now()->diffInSeconds($this->snatch->completedat->addHours($inspectTime));
return mkprettytime($diffInSeconds); return mkprettytime($diffInSeconds);
} }
@@ -72,7 +77,12 @@ class HitAndRun extends NexusModel
if ($this->status != self::STATUS_INSPECTING) { if ($this->status != self::STATUS_INSPECTING) {
return '---'; return '---';
} }
$seedTimeMinimum = HitAndRun::getConfig('seed_time_minimum', $this->torrent->basic_category->mode); $searchBoxId = $this->torrent->basic_category->mode ?? 0;
if ($searchBoxId == 0) {
do_log(sprintf('[INVALID_CATEGORY], Torrent: %s', $this->torrent_id), 'error');
return '---';
}
$seedTimeMinimum = HitAndRun::getConfig('seed_time_minimum', $searchBoxId);
$diffInSeconds = 3600 * $seedTimeMinimum - $this->snatch->seedtime; $diffInSeconds = 3600 * $seedTimeMinimum - $this->snatch->seedtime;
return mkprettytime($diffInSeconds); return mkprettytime($diffInSeconds);
} }

View File

@@ -303,7 +303,12 @@ class Torrent extends NexusModel
public function getHrAttribute(): string public function getHrAttribute(): string
{ {
// $hrMode = Setting::get('hr.mode'); // $hrMode = Setting::get('hr.mode');
$hrMode = HitAndRun::getConfig('mode', $this->basic_category->mode); $searchBoxId = $this->basic_category->mode ?? 0;
if ($searchBoxId == 0) {
do_log(sprintf('[INVALID_CATEGORY], Torrent: %s, category: %s invalid', $this->id, $this->category), 'error');
return self::HR_NO;
}
$hrMode = HitAndRun::getConfig('mode', $searchBoxId);
if ($hrMode == HitAndRun::MODE_GLOBAL) { if ($hrMode == HitAndRun::MODE_GLOBAL) {
return self::HR_YES; return self::HR_YES;
} }

View File

@@ -301,8 +301,12 @@ class SearchRepository extends BaseRepository
$idName => $this->getTorrentId($torrent->id), $idName => $this->getTorrentId($torrent->id),
'routing' => $torrent->owner, 'routing' => $torrent->owner,
]; ];
$searchBoxId = $torrent->basic_category->mode ?? 0;
if ($searchBoxId == 0) {
do_log(sprintf('[INVALID_CATEGORY], Torrent: %s', $torrent->id), 'error');
}
$data = Arr::only($torrent->toArray(), $baseFields); $data = Arr::only($torrent->toArray(), $baseFields);
$data['mode'] = $torrent->basic_category->mode; $data['mode'] = $searchBoxId;
$body = array_merge($data, [ $body = array_merge($data, [
'_doc_type' => $docType, '_doc_type' => $docType,
'torrent_id' => $torrent->id, 'torrent_id' => $torrent->id,

View File

@@ -1093,7 +1093,12 @@ class TrackerRepository extends BaseRepository
return; return;
} }
// $hrMode = Setting::get('hr.mode'); // $hrMode = Setting::get('hr.mode');
$hrMode = HitAndRun::getConfig('mode', $torrent->basic_category->mode); $searchBoxId = $torrent->basic_category->mode ?? 0;
if ($searchBoxId == 0) {
do_log(sprintf('[INVALID_CATEGORY], Torrent: %s', $torrent->id), 'error');
return;
}
$hrMode = HitAndRun::getConfig('mode', $searchBoxId);
if ($hrMode == HitAndRun::MODE_DISABLED) { if ($hrMode == HitAndRun::MODE_DISABLED) {
return; return;
} }

View File

@@ -1,6 +1,6 @@
<?php <?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.30'); defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.30');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-11-02'); defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-11-05');
defined('IN_TRACKER') || define('IN_TRACKER', false); defined('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP"); defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org"); defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");

View File

@@ -5727,7 +5727,12 @@ function can_access_torrent($torrent)
if (is_array($torrent) && isset($torrent['search_box_id'])) { if (is_array($torrent) && isset($torrent['search_box_id'])) {
$searchBoxId = $torrent['search_box_id']; $searchBoxId = $torrent['search_box_id'];
} elseif (is_numeric($torrent)) { } elseif (is_numeric($torrent)) {
$searchBoxId = \App\Models\Torrent::query()->findOrFail(intval($torrent), ['id', 'category'])->basic_category->mode; $torrent = \App\Models\Torrent::query()->findOrFail(intval($torrent), ['id', 'category']);
$searchBoxId = $torrent->basic_category->mode ?? 0;
if ($searchBoxId == 0) {
do_log("[INVALID_CATEGORY], torrent: " . $torrent->id, 'error');
return false;
}
} else { } else {
throw new \InvalidArgumentException("Unsupported argument: " . json_encode($torrent)); throw new \InvalidArgumentException("Unsupported argument: " . json_encode($torrent));
} }