Skip to content

Commit

Permalink
Merge branch '7.x.x' into block-reserved-ports
Browse files Browse the repository at this point in the history
  • Loading branch information
HDVinnie committed Jan 2, 2024
2 parents c26e223 + 81f45ab commit cf6526e
Show file tree
Hide file tree
Showing 84 changed files with 1,793 additions and 5,863 deletions.
20 changes: 12 additions & 8 deletions app/Http/Controllers/AnnounceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,14 @@ private function checkAnnounceFields(Request $request): array
}
}

foreach (['uploaded', 'downloaded', 'left'] as $item) {
foreach (['port', 'uploaded', 'downloaded', 'left'] as $item) {
$itemData = $queries[$item];

if (!is_numeric($itemData) || $itemData < 0) {
throw new TrackerException(134, [':attribute' => $item]);
}

$queries[$item] = (int) $itemData;
}

// Part.2 Extract optional announce fields
Expand All @@ -252,6 +254,8 @@ private function checkAnnounceFields(Request $request): array
if (!is_numeric($queries[$item]) || $queries[$item] < 0) {
throw new TrackerException(134, [':attribute' => $item]);
}

$queries[$item] = (int) $queries[$item];
}

$queries['event'] = strtolower($queries['event']);
Expand Down Expand Up @@ -307,7 +311,7 @@ private function checkUser(string $passkey, array $queries): object
}

// If User Download Rights Are Disabled Return Error to Client
if ($user->can_download === false && $queries['left'] !== '0') {
if ($user->can_download === false && $queries['left'] !== 0) {
throw new TrackerException(142);
}

Expand Down Expand Up @@ -506,7 +510,7 @@ private function checkDownloadSlots(array $queries, object $torrent, object $use

$isNewPeer = $peer === null;
$isDeadPeer = $queries['event'] === 'stopped';
$isSeeder = $queries['left'] == 0;
$isSeeder = $queries['left'] === 0;

$newLeech = $isNewPeer && !$isDeadPeer && !$isSeeder;
$stoppedLeech = !$isNewPeer && $isDeadPeer && !$isSeeder;
Expand Down Expand Up @@ -553,11 +557,11 @@ private function generateSuccessAnnounceResponse(array $queries, object $torrent
* For non `stopped` event only where either the torrent has at least one leech, or the user is a leech.
* We query peers from database and send peerlist, otherwise just quick return.
*/
if ($queries['event'] !== 'stopped' && ($queries['left'] != 0 || $torrent->leechers !== 0)) {
if ($queries['event'] !== 'stopped' && ($queries['left'] !== 0 || $torrent->leechers !== 0)) {
$limit = (min($queries['numwant'], 25));

// Get Torrents Peers (Only include leechers in a seeder's peerlist)
if ($queries['left'] == 0) {
if ($queries['left'] === 0) {
foreach ($torrent->peers as $peer) {
// Don't include other seeders, inactive peers, nor other peers belonging to the same user
if ($peer->seeder || !$peer->active || $peer->user_id === $user->id) {
Expand Down Expand Up @@ -715,7 +719,7 @@ private function processAnnounceJob(array $queries, object $user, object $group,
$queries['uploaded'],
$queries['downloaded'],
$queries['left'],
$queries['left'] == 0,
$queries['left'] === 0,
$torrent->id,
$user->id,
$event !== 'stopped',
Expand All @@ -738,7 +742,7 @@ private function processAnnounceJob(array $queries, object $user, object $group,
'downloaded' => $event === 'started' ? 0 : $creditedDownloadedDelta,
'actual_downloaded' => $event === 'started' ? 0 : $downloadedDelta,
'client_downloaded' => $queries['downloaded'],
'seeder' => $queries['left'] == 0,
'seeder' => $queries['left'] === 0,
'active' => $event !== 'stopped',
'seedtime' => 0,
'immune' => $group->is_immune,
Expand Down Expand Up @@ -774,7 +778,7 @@ private function processAnnounceJob(array $queries, object $user, object $group,

$isNewPeer = $isNewPeer || !$peer->active;
$isDeadPeer = $event === 'stopped';
$isSeeder = $queries['left'] == 0;
$isSeeder = $queries['left'] === 0;

$newSeed = $isNewPeer && !$isDeadPeer && $isSeeder;
$newLeech = $isNewPeer && !$isDeadPeer && !$isSeeder;
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/MediaHub/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function index(): \Illuminate\Contracts\View\Factory|\Illuminate\View\Vie
'tv' => Tv::count(),
'movies' => Movie::count(),
'movieCategoryIds' => Category::where('movie_meta', '=', 1)->pluck('id')->toArray(),
'tvCategoryIds' => Category::where('tv_meta', '=', 1)->pluck('id')->toArray(),
'collections' => Collection::count(),
'persons' => Person::whereNotNull('still')->count(),
'genres' => Genre::count(),
Expand Down
34 changes: 0 additions & 34 deletions app/Http/Controllers/MediaHub/TvSeasonController.php

This file was deleted.

40 changes: 0 additions & 40 deletions app/Http/Controllers/MediaHub/TvShowController.php

This file was deleted.

1 change: 1 addition & 0 deletions app/Http/Livewire/PersonCredit.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ function ($tv) {
),
'Specials' => $packOrSpecialOrSeasons
->groupBy(fn ($torrent) => 'Special '.$torrent->episode_number)
->sortKeys(SORT_NATURAL)
->map(
fn ($episode) => $episode
->sortBy('type.position')
Expand Down
1 change: 1 addition & 0 deletions app/Http/Livewire/TorrentSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ function ($tv) {
),
'Specials' => $packOrSpecialOrSeasons
->groupBy(fn ($torrent) => 'Special '.$torrent->episode_number)
->sortKeys(SORT_NATURAL)
->map(
fn ($episode) => $episode
->sortBy('type.position')
Expand Down
8 changes: 6 additions & 2 deletions app/Http/Livewire/UserWarnings.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class UserWarnings extends Component

public int $perPage = 10;

public string $sortField = 'created_at';
public ?string $sortField = null;

public string $sortDirection = 'desc';

Expand Down Expand Up @@ -66,7 +66,11 @@ final public function getWarningsProperty(): \Illuminate\Contracts\Pagination\Le
->when($this->warningTab === 'automated', fn ($query) => $query->whereNotNull('torrent'))
->when($this->warningTab === 'manual', fn ($query) => $query->whereNull('torrent'))
->when($this->warningTab === 'deleted', fn ($query) => $query->onlyTrashed())
->orderBy($this->sortField, $this->sortDirection)
->when(
$this->sortField === null,
fn ($query) => $query->orderByDesc('active')->orderByDesc('created_at'),
fn ($query) => $query->orderBy($this->sortField, $this->sortDirection),
)
->paginate($this->perPage);
}

Expand Down
7 changes: 7 additions & 0 deletions resources/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
@import 'vendor/alpinejs';

// Base
@import 'base/normalize';
@import 'base/typography';
@import 'base/reset';
@import 'base/scrollbar';

// Components
Expand All @@ -14,13 +16,16 @@
@import 'chat/chatbox';
@import 'main/tooltips';
@import 'components/achievement';
@import 'components/alert';
@import 'components/article-preview';
@import 'components/bbcode-input';
@import 'components/bbcode-rendered';
@import 'components/collection-card';
@import 'components/comment';
@import 'components/comparison';
@import 'components/data-table';
@import 'components/dialog';
@import 'components/emoji';
@import 'components/featured-pane';
@import 'components/form/button';
@import 'components/form/checkbox';
Expand All @@ -40,12 +45,14 @@
@import 'components/forum/topic-listing';
@import 'components/forum/topic-tag';
@import 'components/key-value';
@import 'components/mediahub-card';
@import 'components/mediainfo';
@import 'components/meta';
@import 'components/pagination';
@import 'components/panel';
@import 'components/playlist';
@import 'components/quick_search';
@import 'components/swal';
@import 'components/torrent-card';
@import 'components/user-active';
@import 'components/user-card';
Expand Down
Loading

0 comments on commit cf6526e

Please sign in to comment.