mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-15 05:00:49 +08:00
add configuration: torrent.approval_status_none_visible
This commit is contained in:
@@ -12,14 +12,14 @@ class NexusUpdate extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'nexus:update';
|
||||
protected $signature = 'nexus:update {--tag=} {--keep_tmp}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update nexusphp after code updated, remember run `composer update` first.';
|
||||
protected $description = 'Update nexusphp after code updated, remember run `composer update` first. Options: --tag=, --keep_tmp';
|
||||
|
||||
private $update;
|
||||
|
||||
@@ -43,6 +43,17 @@ class NexusUpdate extends Command
|
||||
{
|
||||
define('WITH_LARAVEL', true);
|
||||
require ROOT_PATH . 'nexus/Database/helpers.php';
|
||||
$tag = $this->option('tag');
|
||||
$keepTmp = $this->option('keep_tmp');
|
||||
if ($tag !== null) {
|
||||
if ($tag === 'dev') {
|
||||
$url = "https://github.com/xiaomlove/nexusphp/archive/refs/heads/php8.zip";
|
||||
} else {
|
||||
$url = "https://api.github.com/repos/xiaomlove/nexusphp/tarball/v$tag";
|
||||
}
|
||||
$this->doLog("Specific tag: '$tag', download from '$url' and extra code...");
|
||||
$tmpPath = $this->update->downAndExtractCode($url);
|
||||
}
|
||||
//Step 1
|
||||
$step = $this->update->currentStep();
|
||||
$log = sprintf('Step %s, %s...', $step, $this->update->getStepName($step));
|
||||
@@ -108,6 +119,15 @@ class NexusUpdate extends Command
|
||||
|
||||
$this->doLog("All done!");
|
||||
|
||||
if (isset($tmpPath)) {
|
||||
if (!$keepTmp) {
|
||||
$this->doLog("Delete tmp files in: $tmpPath");
|
||||
$this->update->executeCommand("rm -rf " . rtrim($tmpPath, '/'));
|
||||
} else {
|
||||
$this->doLog("Keep tmp files in: $tmpPath");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,8 +78,13 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$r = Carbon::parse(null);
|
||||
dd($r);
|
||||
$a = 2;
|
||||
$b = 2;
|
||||
if ($a != 1 && $b == 2) {
|
||||
echo "OK";
|
||||
} else {
|
||||
echo 'Bad';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -533,5 +533,36 @@ class TorrentRepository extends BaseRepository
|
||||
|
||||
}
|
||||
|
||||
public function renderApprovalStatus($approvalStatus, $show = null): string
|
||||
{
|
||||
if ($show === null) {
|
||||
$show = $this->shouldShowApprovalStatusIcon($approvalStatus);
|
||||
}
|
||||
if ($show) {
|
||||
return sprintf(
|
||||
'<span style="margin-left: 6px" title="%s">%s</span>',
|
||||
nexus_trans("torrent.approval.status_text.$approvalStatus"),
|
||||
\App\Models\Torrent::$approvalStatus[$approvalStatus]['icon']
|
||||
);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
public function shouldShowApprovalStatusIcon($approvalStatus): bool
|
||||
{
|
||||
if (get_setting('torrent.approval_status_icon_enabled') == 'yes') {
|
||||
//启用审核状态图标,肯定显示
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
$approvalStatus != \App\Models\Torrent::APPROVAL_STATUS_ALLOW
|
||||
&& get_setting('torrent.approval_status_none_visible') == 'no'
|
||||
) {
|
||||
//不启用审核状态图标,尽量不显示。在种子不是审核通过状态,而审核不通过又不能被用户看到时,显示
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -382,8 +382,13 @@ class TrackerRepository extends BaseRepository
|
||||
throw new TrackerException('Torrent not registered with this tracker.');
|
||||
}
|
||||
|
||||
if ($torrent->banned == 'yes' && $user->class < Setting::get('authority.seebanned')) {
|
||||
throw new TrackerException("torrent banned");
|
||||
if ($user->class < Setting::get('authority.seebanned')) {
|
||||
if ($torrent->banned == 'yes') {
|
||||
throw new TrackerException("torrent banned");
|
||||
}
|
||||
if ($torrent->approval_status != Torrent::APPROVAL_STATUS_ALLOW && Setting::get('torrent.approval_status_none_visible') == 'no') {
|
||||
throw new TrackerException("torrent review not approved");
|
||||
}
|
||||
}
|
||||
return $torrent;
|
||||
}
|
||||
@@ -1066,7 +1071,7 @@ class TrackerRepository extends BaseRepository
|
||||
{
|
||||
$cacheKey = __METHOD__ . bin2hex($infoHash);
|
||||
return Cache::remember($cacheKey, 60, function () use ($infoHash, $cacheKey) {
|
||||
$fieldRaw = 'id, owner, sp_state, seeders, leechers, added, banned, hr, visible, last_action, times_completed';
|
||||
$fieldRaw = 'id, owner, sp_state, seeders, leechers, added, banned, hr, visible, last_action, times_completed, approval_status';
|
||||
$torrent = Torrent::query()->where('info_hash', $infoHash)->selectRaw($fieldRaw)->first();
|
||||
do_log("[getTorrentByInfoHash] cache miss [$cacheKey], from database, and get: " . ($torrent->id ?? ''));
|
||||
return $torrent;
|
||||
|
||||
Reference in New Issue
Block a user