Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/Bots/NerdBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class NerdBot
public function __construct(private readonly ChatRepository $chatRepository)
{
$this->bot = Bot::query()->findOrFail(2);
$this->expiresAt = Carbon::now()->addMinutes(60);
$this->current = Carbon::now();
$this->expiresAt = now()->addMinutes(60);
$this->current = now();
$this->site = config('other.title');
}

Expand Down
3 changes: 1 addition & 2 deletions app/Console/Commands/AutoCorrectHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

use App\Models\History;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Exception;
use Illuminate\Support\Facades\DB;
use Throwable;
Expand Down Expand Up @@ -49,7 +48,7 @@ final public function handle(): void
History::query()
->withTrashed()
->where('active', '=', 1)
->where('updated_at', '<', Carbon::now()->subHours(2))
->where('updated_at', '<', now()->subHours(2))
->update([
'active' => 0,
'updated_at' => DB::raw('updated_at'),
Expand Down
5 changes: 1 addition & 4 deletions app/Console/Commands/AutoDeactivateWarning.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use App\Models\Warning;
use App\Notifications\UserWarningExpired;
use App\Services\Unit3dAnnounce;
use Carbon\Carbon;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
Expand Down Expand Up @@ -48,15 +47,13 @@ class AutoDeactivateWarning extends Command
*/
final public function handle(): void
{
$current = Carbon::now();

$usersWithExpiredWarnings = [];

Warning::query()
->where('active', '=', true)
->where(
fn ($query) => $query
->where('expires_on', '<=', $current)
->where('expires_on', '<=', now())
->orWhereHas(
'torrent.history',
fn ($query) => $query
Expand Down
9 changes: 3 additions & 6 deletions app/Console/Commands/AutoDisableInactiveUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use App\Models\User;
use App\Services\Unit3dAnnounce;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Exception;
use Throwable;

Expand Down Expand Up @@ -54,19 +53,17 @@ final public function handle(): void

$disabledGroupId = Group::query()->where('slug', '=', 'disabled')->soleValue('id');

$current = Carbon::now();

User::query()
->whereIntegerInRaw('group_id', config('pruning.group_ids'))
->where('created_at', '<', $current->copy()->subDays(config('pruning.account_age')))
->where('last_login', '<', $current->copy()->subDays(config('pruning.last_login')))
->where('created_at', '<', now()->subDays(config('pruning.account_age')))
->where('last_login', '<', now()->subDays(config('pruning.last_login')))
->whereDoesntHave('seedingTorrents')
->chunk(100, function ($users) use ($disabledGroupId): void {
foreach ($users as $user) {
$user->update([
'group_id' => $disabledGroupId,
'can_download' => false,
'disabled_at' => Carbon::now(),
'disabled_at' => now(),
]);

cache()->forget('user:'.$user->passkey);
Expand Down
8 changes: 3 additions & 5 deletions app/Console/Commands/AutoFlushPeers.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use App\Models\History;
use App\Models\Peer;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Exception;
use Illuminate\Support\Facades\DB;
use Throwable;
Expand Down Expand Up @@ -47,10 +46,9 @@ class AutoFlushPeers extends Command
*/
final public function handle(): void
{
$carbon = new Carbon();
$peers = Peer::query()
->select(['torrent_id', 'user_id', 'peer_id', 'seeder', 'updated_at'])
->where('updated_at', '<', $carbon->copy()->subHours(2))
->where('updated_at', '<', now()->subHours(2))
->where('active', '=', 1)
->get();

Expand Down Expand Up @@ -78,13 +76,13 @@ final public function handle(): void
// next 2 days
if (config('announce.external_tracker.is_enabled')) {
Peer::query()
->where('updated_at', '<', $carbon->copy()->subDays(2))
->where('updated_at', '<', now()->subDays(2))
->where('active', '=', 0)
->delete();
} else {
$peers = Peer::query()
->select(['torrent_id', 'user_id', 'peer_id'])
->where('updated_at', '<', $carbon->copy()->subDays(2))
->where('updated_at', '<', now()->subDays(2))
->where('active', '=', 0)
->get();

Expand Down
4 changes: 1 addition & 3 deletions app/Console/Commands/AutoRefundDownload.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use App\Models\History;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Throwable;

Expand All @@ -46,7 +45,6 @@ class AutoRefundDownload extends Command
*/
final public function handle(): void
{
$now = Carbon::now();
$MIN_SEEDTIME = config('hitrun.seedtime');
$FULL_REFUND_SEEDTIME = 12 * 30 * 24 * 60 * 60 + $MIN_SEEDTIME;
$COMMAND_RUN_PERIOD = 24 * 60 * 60; // This command is run every 24 hours
Expand All @@ -60,7 +58,7 @@ final public function handle(): void
->where('history.seeder', '=', 1)
->where('history.seedtime', '>=', $MIN_SEEDTIME)
->where('history.seedtime', '<=', $FULL_REFUND_SEEDTIME + $MIN_SEEDTIME + $COMMAND_RUN_PERIOD)
->where('history.created_at', '<=', $now->copy()->subSeconds($MIN_SEEDTIME))
->where('history.created_at', '<=', now()->subSeconds($MIN_SEEDTIME))
->whereColumn('torrents.user_id', '!=', 'history.user_id')
->when(!config('other.refundable'), fn ($query) => $query->where(
fn ($query) => $query
Expand Down
3 changes: 1 addition & 2 deletions app/Console/Commands/AutoRemoveExpiredDonors.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use App\Services\Unit3dAnnounce;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Notification;
use Throwable;

Expand Down Expand Up @@ -53,7 +52,7 @@ final public function handle(): void
->where('is_lifetime', '=', false)
->whereHas('donations')
->whereDoesntHave('donations', function ($query): void {
$query->where('ends_at', '>', Carbon::now());
$query->where('ends_at', '>', now());
})->get();

Notification::send($expiredDonors, new DonationExpired());
Expand Down
4 changes: 1 addition & 3 deletions app/Console/Commands/AutoRemoveFeaturedTorrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use App\Services\Unit3dAnnounce;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Throwable;

class AutoRemoveFeaturedTorrent extends Command
Expand Down Expand Up @@ -56,8 +55,7 @@ public function __construct(private readonly ChatRepository $chatRepository)
*/
final public function handle(): void
{
$current = Carbon::now();
$featuredTorrents = FeaturedTorrent::query()->with('torrent')->where('created_at', '<', $current->copy()->subDays(7))->get();
$featuredTorrents = FeaturedTorrent::query()->with('torrent')->where('created_at', '<', now()->subDays(7))->get();

foreach ($featuredTorrents as $featuredTorrent) {
// Find The Torrent
Expand Down
4 changes: 1 addition & 3 deletions app/Console/Commands/AutoRemovePersonalFreeleech.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use App\Services\Unit3dAnnounce;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Notification;
use Throwable;

Expand All @@ -49,8 +48,7 @@ class AutoRemovePersonalFreeleech extends Command
*/
final public function handle(): void
{
$current = Carbon::now();
$personalFreeleech = PersonalFreeleech::query()->where('created_at', '<', $current->copy()->subDays(1))->get();
$personalFreeleech = PersonalFreeleech::query()->where('created_at', '<', now()->subDays(1))->get();

foreach ($personalFreeleech as $pfl) {
Notification::send(new User(['id' => $pfl->user_id]), new PersonalFreeleechDeleted());
Expand Down
5 changes: 2 additions & 3 deletions app/Console/Commands/AutoRemoveTimedTorrentBuffs.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use App\Services\Unit3dAnnounce;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Throwable;

Expand All @@ -47,7 +46,7 @@ class AutoRemoveTimedTorrentBuffs extends Command
*/
final public function handle(): void
{
$flTorrents = Torrent::query()->whereNotNull('fl_until')->where('fl_until', '<', Carbon::now())->get();
$flTorrents = Torrent::query()->whereNotNull('fl_until')->where('fl_until', '<', now())->get();

foreach ($flTorrents as $torrent) {
$torrent->update([
Expand All @@ -59,7 +58,7 @@ final public function handle(): void
Unit3dAnnounce::addTorrent($torrent);
}

$duTorrents = Torrent::query()->whereNotNull('du_until')->where('du_until', '<', Carbon::now())->get();
$duTorrents = Torrent::query()->whereNotNull('du_until')->where('du_until', '<', now())->get();

foreach ($duTorrents as $torrent) {
$torrent->update([
Expand Down
5 changes: 2 additions & 3 deletions app/Console/Commands/AutoRewardResurrection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use App\Services\Unit3dAnnounce;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Throwable;

class AutoRewardResurrection extends Command
Expand Down Expand Up @@ -83,9 +82,9 @@ final public function handle(): void
$torrentUrl = href_torrent($resurrection->torrent);

$resurrection->torrent->update([
'bumped_at' => Carbon::now(),
'bumped_at' => now(),
'free' => 100,
'fl_until' => Carbon::now()->addDays(3),
'fl_until' => now()->addDays(3),
]);

$this->chatRepository->systemMessage(
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/AutoSoftDeleteDisabledUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ final public function handle(): void
}

$users = User::query()->whereRelation('group', 'slug', '=', 'disabled')
->where('disabled_at', '<', now()->copy()->subDays(config('pruning.soft_delete')))
->where('disabled_at', '<', now()->subDays(config('pruning.soft_delete')))
->get();

foreach ($users as $user) {
Expand Down
6 changes: 2 additions & 4 deletions app/Console/Commands/AutoWarning.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use App\Models\Warning;
use App\Notifications\UserWarning;
use App\Services\Unit3dAnnounce;
use Illuminate\Support\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Exception;
Expand Down Expand Up @@ -54,7 +53,6 @@ final public function handle(): void
return;
}

$carbon = new Carbon();
$hitrun = History::query()
->with(['user', 'torrent'])
->where('actual_downloaded', '>', 0)
Expand All @@ -63,7 +61,7 @@ final public function handle(): void
->where('immune', '=', 0)
->where('active', '=', 0)
->where('seedtime', '<', config('hitrun.seedtime'))
->where('updated_at', '<', $carbon->copy()->subDays(config('hitrun.grace')))
->where('updated_at', '<', now()->subDays(config('hitrun.grace')))
->whereRelation('user.group', 'is_immune', '=', false)
->whereRelation('user', 'is_donor', '=', false)
->whereHas('torrent', fn ($query) => $query->whereRaw('history.actual_downloaded > torrents.size * ?', [config('hitrun.buffer') / 100]))
Expand All @@ -78,7 +76,7 @@ final public function handle(): void
'warned_by' => User::SYSTEM_USER_ID,
'torrent_id' => $hr->torrent->id,
'reason' => \sprintf('Hit and Run Warning For Torrent %s', $hr->torrent->name),
'expires_on' => $carbon->copy()->addDays(config('hitrun.expire')),
'expires_on' => now()->addDays(config('hitrun.expire')),
'active' => true,
]);

Expand Down
3 changes: 1 addition & 2 deletions app/Helpers/EmailBlacklistUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

namespace App\Helpers;

use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Http;
use Exception;

Expand All @@ -32,7 +31,7 @@ public static function update(): bool|int

// Define parameters for the cache
$key = config('email-blacklist.cache-key');
$duration = Carbon::now()->addMonth();
$duration = now()->addMonth();

if (cache()->get($key) === null) {
try {
Expand Down
5 changes: 2 additions & 3 deletions app/Helpers/TorrentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
use App\Notifications\NewUpload;
use App\Notifications\NewWishListNotice;
use App\Services\Unit3dAnnounce;
use Illuminate\Support\Carbon;

class TorrentHelper
{
Expand All @@ -49,8 +48,8 @@ public static function approveHelper(int $id): void
$appurl = config('app.url');

$torrent = Torrent::query()->with('user')->withoutGlobalScope(ApprovedScope::class)->findOrFail($id);
$torrent->created_at = Carbon::now();
$torrent->bumped_at = Carbon::now();
$torrent->created_at = now();
$torrent->bumped_at = now();
$torrent->status = ModerationStatus::APPROVED;
$torrent->moderated_at = now();
$torrent->moderated_by = (int) auth()->id();
Expand Down
7 changes: 3 additions & 4 deletions app/Http/Controllers/API/TorrentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
use Exception;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Storage;
use Illuminate\Validation\Rule;
use Meilisearch\Endpoints\Indexes;
Expand Down Expand Up @@ -190,7 +189,7 @@ public function store(Request $request): \Illuminate\Http\JsonResponse

/** @phpstan-ignore property.notFound (Larastan doesn't yet support loadExists()) */
if (($user->group->is_modo || $user->internals_exists) && isset($du_until)) {
$torrent->du_until = Carbon::now()->addDays($request->integer('du_until'));
$torrent->du_until = now()->addDays($request->integer('du_until'));
}

/** @phpstan-ignore property.notFound (Larastan doesn't yet support loadExists()) */
Expand All @@ -199,12 +198,12 @@ public function store(Request $request): \Illuminate\Http\JsonResponse

/** @phpstan-ignore property.notFound (Larastan doesn't yet support loadExists()) */
if (($user->group->is_modo || $user->internals_exists) && isset($fl_until)) {
$torrent->fl_until = Carbon::now()->addDays($request->integer('fl_until'));
$torrent->fl_until = now()->addDays($request->integer('fl_until'));
}

/** @phpstan-ignore property.notFound (Larastan doesn't yet support loadExists()) */
$torrent->sticky = $user->group->is_modo || $user->internals_exists ? ($request->input('sticky') ?? false) : false;
$torrent->moderated_at = Carbon::now();
$torrent->moderated_at = now();
$torrent->moderated_by = User::SYSTEM_USER_ID;

$mustBeNull = function (string $attribute, mixed $value, callable $fail): void {
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/ApprovedRequestFillController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use App\Notifications\NewRequestFillApprove;
use App\Repositories\ChatRepository;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;

/**
* @see \Tests\Todo\Feature\Http\Controllers\RequestControllerTest
Expand All @@ -50,7 +49,7 @@ public function store(Request $request, TorrentRequest $torrentRequest): \Illumi

$torrentRequest->update([
'approved_by' => $approver->id,
'approved_when' => Carbon::now(),
'approved_when' => now(),
]);

$filler->increment('seedbonus', (float) $torrentRequest->bounty);
Expand Down
5 changes: 2 additions & 3 deletions app/Http/Controllers/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

use App\Models\Group;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;

class GroupController extends Controller
Expand All @@ -31,10 +30,10 @@ public function index(Request $request): \Illuminate\Contracts\View\Factory|\Ill
$user = $request->user();

return view('group.index', [
'current' => Carbon::now(),
'current' => now(),
'user' => $user,
'user_avg_seedtime' => DB::table('history')->where('user_id', '=', $user->id)->avg('seedtime'),
'user_account_age' => (int) Carbon::now()->diffInSeconds($user->created_at, true),
'user_account_age' => (int) now()->diffInSeconds($user->created_at, true),
'user_seed_size' => $user->seedingTorrents()->sum('size'),
'user_uploads' => $user->torrents()->count(),
'groups' => Group::query()->orderBy('position')->where('is_modo', '=', 0)->get(),
Expand Down
Loading
Loading