mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
announce only check paid torrent for leechers
This commit is contained in:
@@ -95,8 +95,9 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$r = nexus_env('PHP_PATH') ?: 'php';
|
||||
dd($r);
|
||||
$now = Carbon::now();
|
||||
$now->addSeconds();
|
||||
dd($diffInSeconds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,9 +31,10 @@ class Torrent extends NexusModel
|
||||
];
|
||||
|
||||
public static $commentFields = [
|
||||
'id', 'name', 'added', 'visible', 'banned', 'owner', 'sp_state', 'pos_state', 'hr', 'picktype', 'picktime',
|
||||
'last_action', 'leechers', 'seeders', 'times_completed', 'views', 'size', 'cover', 'anonymous', 'approval_status',
|
||||
'pos_state_until', 'category', 'source', 'medium', 'codec', 'standard', 'processing', 'team', 'audiocodec', 'price'
|
||||
'id', 'name', 'added', 'visible', 'banned', 'owner', 'sp_state', 'promotion_time_type', 'promotion_until', 'pos_state',
|
||||
'hr', 'picktype', 'picktime', 'last_action', 'leechers', 'seeders', 'times_completed', 'views', 'size', 'cover', 'anonymous',
|
||||
'approval_status', 'pos_state_until', 'category', 'source', 'medium', 'codec', 'standard', 'processing', 'team', 'audiocodec',
|
||||
'price',
|
||||
];
|
||||
|
||||
public static $basicRelations = [
|
||||
|
||||
@@ -479,7 +479,7 @@ class TorrentRepository extends BaseRepository
|
||||
{
|
||||
$user = $this->getUser($user);
|
||||
user_can('torrent-approval', true);
|
||||
$torrent = Torrent::query()->findOrFail($params['torrent_id'], ['id', 'banned', 'approval_status', 'visible', 'owner']);
|
||||
$torrent = Torrent::query()->findOrFail($params['torrent_id'], Torrent::$commentFields);
|
||||
$lastLog = TorrentOperationLog::query()
|
||||
->where('torrent_id', $params['torrent_id'])
|
||||
->where('uid', $user->id)
|
||||
@@ -497,6 +497,21 @@ class TorrentRepository extends BaseRepository
|
||||
$torrentUpdate['visible'] = 'yes';
|
||||
if ($torrent->approval_status != $params['approval_status']) {
|
||||
$torrentOperationLog['action_type'] = TorrentOperationLog::ACTION_TYPE_APPROVAL_ALLOW;
|
||||
//increase promotion time
|
||||
if (
|
||||
Setting::get('torrent.approval_status_none_visible') == 'no'
|
||||
&& $torrent->sp_state != Torrent::PROMOTION_NORMAL
|
||||
&& $torrent->promotion_until
|
||||
) {
|
||||
$hasBeenDownloaded = Snatch::query()->where('torrentid', $torrent->id)->exists();
|
||||
$log = "Torrent: {$torrent->id} is in promotion, hasBeenDownloaded: $hasBeenDownloaded";
|
||||
if (!$hasBeenDownloaded) {
|
||||
$diffInSeconds = $torrent->promotion_until->diffInSeconds($torrent->added);
|
||||
$log .= ", addSeconds: $diffInSeconds";
|
||||
$torrentUpdate['promotion_until'] = $torrent->promotion_until->addSeconds($diffInSeconds);
|
||||
}
|
||||
do_log($log);
|
||||
}
|
||||
}
|
||||
if ($torrent->approval_status == Torrent::APPROVAL_STATUS_DENY) {
|
||||
$notifyUser = true;
|
||||
@@ -519,6 +534,7 @@ class TorrentRepository extends BaseRepository
|
||||
} else {
|
||||
throw new \InvalidArgumentException("Invalid approval_status: " . $params['approval_status']);
|
||||
}
|
||||
|
||||
if (isset($torrentOperationLog['action_type'])) {
|
||||
$torrentOperationLog['uid'] = $user->id;
|
||||
$torrentOperationLog['torrent_id'] = $torrent->id;
|
||||
|
||||
Reference in New Issue
Block a user