Skip to content

Commit

Permalink
Merge pull request #1558 from NNTmux/laravel11
Browse files Browse the repository at this point in the history
Laravel11
  • Loading branch information
DariusIII authored Apr 28, 2024
2 parents 83122f9 + 2c3b95c commit e0f5174
Show file tree
Hide file tree
Showing 263 changed files with 5,227 additions and 2,943 deletions.
19 changes: 15 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,24 @@ ADMIN_EMAIL=
APP_NAME=NNTmux
APP_ENV=production
APP_DEBUG=false
APP_TIMEZONE=UTC
APP_URL=
APP_TZ=Europe/Paris

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database

BCRYPT_ROUNDS=12
APP_KEY=
LOG_CHANNEL=stack
LOG_STACK=single
PASSWORD_HASH=argon2id

BROADCAST_DRIVER=log
CACHE_DRIVER=redis
BROADCAST_CONNECTION=log
CACHE_STORE=redis
QUEUE_CONNECTION=sync

REDIS_HOST=127.0.0.1
Expand All @@ -61,10 +71,11 @@ REDIS_PORT=6379
REDIS_CLIENT=phpredis

SESSION_DRIVER=redis
SESSION_DOMAIN=
SESSION_DOMAIN=null
SESSION_SECURE_COOKIE=false
SESSION_ENCRYPT=false
SESSION_COOKIE=nntmux
SESSION_PATH=/

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
Expand Down
23 changes: 14 additions & 9 deletions .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ on: [push]

jobs:
tests:
name: Run tests
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [ 8.2, 8.3 ]

name: PHP ${{ matrix.php }}
services:
mysql:
image: mariadb:10
Expand All @@ -18,25 +24,24 @@ jobs:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, bcmath, soap, intl, gd, exif, iconv
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
coverage: none

- name: Copy env file
run:
cp .env.test .env

- name: Run composer install
run: composer install -n --prefer-dist
run: composer install --prefer-dist --no-interaction --no-progress

- name: Prepare Laravel Application
run:
php artisan key:generate
- name: Generate app key
run: php artisan key:generate

- name: Run tests
run: php artisan test
run: vendor/bin/phpunit
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
->in(config_path())
->in(database_path())
->notPath(database_path('migrations'))
->in(resource_path('lang'))
->in(base_path('lang'))
->in(base_path('routes'))
->in(base_path('tests'))
->in(base_path('Blacklight'))
Expand Down
2 changes: 1 addition & 1 deletion Blacklight/Backfill.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function backfillAllGroups(string $groupName = '', int|string $articles =
$counter++;
}

$dMessage = 'Backfilling completed in '.now()->diffInSeconds($allTime).' seconds.';
$dMessage = 'Backfilling completed in '.now()->diffInSeconds($allTime, true).' seconds.';

if ($this->_echoCLI) {
$this->colorCli->primary($dMessage);
Expand Down
16 changes: 8 additions & 8 deletions Blacklight/Binaries.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function updateAllGroups(int $maxHeaders = 100000): void
$counter++;
}

$endTime = now()->diffInSeconds($allTime);
$endTime = now()->diffInSeconds($allTime, true);
$this->log(
'Updating completed in '.$endTime.Str::plural(' second', $endTime),
__FUNCTION__,
Expand Down Expand Up @@ -458,7 +458,7 @@ public function updateGroup(array $groupMySQL, int $maxHeaders = 0): void
}

if ($this->_echoCLI) {
$endGroup = now()->diffInSeconds($startGroup);
$endGroup = now()->diffInSeconds($startGroup, true);
$this->colorCli->primary(
PHP_EOL.'Group '.$groupMySQL['name'].' processed in '.
$endGroup.Str::plural(' second', $endGroup)
Expand Down Expand Up @@ -547,7 +547,7 @@ public function scan(array $groupMySQL, int $first, int $last, string $type = 'u
$this->startCleaning = now();

// End of the getting data from usenet.
$this->timeHeaders = $this->startCleaning->diffInSeconds($this->startLoop);
$this->timeHeaders = $this->startCleaning->diffInSeconds($this->startLoop, true);

// Check if we got headers.
$msgCount = \count($headers);
Expand Down Expand Up @@ -636,7 +636,7 @@ public function scan(array $groupMySQL, int $first, int $last, string $type = 'u
$this->startPR = now();

// End of inserting.
$this->timeInsert = $this->startPR->diffInSeconds($this->startUpdate);
$this->timeInsert = $this->startPR->diffInSeconds($this->startUpdate, true);

if ($partRepair && \count($headersRepaired) > 0) {
$this->removeRepairedParts($headersRepaired, $this->groupMySQL['id']);
Expand Down Expand Up @@ -853,7 +853,7 @@ protected function storeHeaders(array $headers = []): void
$this->startUpdate = now();

// End of processing headers.
$this->timeCleaning = $this->startUpdate->diffInSeconds($this->startCleaning);
$this->timeCleaning = $this->startUpdate->diffInSeconds($this->startCleaning, true);
$binariesQuery = $binariesCheck = 'INSERT INTO binaries (id, partsize, currentparts) VALUES ';
foreach ($binariesUpdate as $binaryID => $binary) {
$binariesQuery .= '('.$binaryID.','.$binary['Size'].','.$binary['Parts'].'),';
Expand Down Expand Up @@ -944,9 +944,9 @@ protected function outputHeaderDuration(): void
$this->colorCli->primaryOver(' to process collections, ').
$this->colorCli->alternateOver($this->timeInsert.'s').
$this->colorCli->primaryOver(' to insert binaries/parts, ').
$this->colorCli->alternateOver($currentMicroTime->diffInSeconds($this->startPR).'s').
$this->colorCli->alternateOver($currentMicroTime->diffInSeconds($this->startPR, true).'s').
$this->colorCli->primaryOver(' for part repair, ').
$this->colorCli->alternateOver($currentMicroTime->diffInSeconds($this->startLoop).'s').
$this->colorCli->alternateOver($currentMicroTime->diffInSeconds($this->startLoop, true).'s').
$this->colorCli->primary(' total.');
}
}
Expand Down Expand Up @@ -1236,7 +1236,7 @@ public function daytopost(int $days, array $data): string
if ($this->_echoCLI) {
$this->colorCli->primary(
PHP_EOL.'Found article #'.$wantedArticle.' which has a date of '.date('r', $articleTime).
', vs wanted date of '.date('r', $goalTime).'. Difference from goal is '.Carbon::createFromTimestamp($goalTime)->diffInDays(Carbon::createFromTimestamp($articleTime)).'days.'
', vs wanted date of '.date('r', $goalTime).'. Difference from goal is '.Carbon::createFromTimestamp($goalTime)->diffInDays(Carbon::createFromTimestamp($articleTime), true).'days.'
);
}

Expand Down
2 changes: 1 addition & 1 deletion Blacklight/Music.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public function processMusicReleases(bool $local = false)

// Sleep to not flood amazon.
$sleeptime = $this->sleeptime / 1000;
$diff = now()->diffInSeconds($startTime);
$diff = now()->diffInSeconds($startTime, true);
if ($sleeptime - $diff > 0 && $usedAmazon === true) {
sleep($sleeptime - $diff);
}
Expand Down
2 changes: 1 addition & 1 deletion Blacklight/NameFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ public function getPreFileNames(array $args = []): void
$this->colorCLI->climate()->info('Renamed Releases: ['.number_format($counted).'] '.(new ConsoleTools())->percentString(++$counter, $total));
}
}
$this->colorCLI->climate()->info(PHP_EOL.'Renamed '.number_format($counted).' releases in '.now()->diffInSeconds($timeStart).' seconds'.'.');
$this->colorCLI->climate()->info(PHP_EOL.'Renamed '.number_format($counted).' releases in '.now()->diffInSeconds($timeStart, true).' seconds'.'.');
} else {
$this->colorCLI->climate()->info('Nothing to do.');
}
Expand Down
4 changes: 2 additions & 2 deletions Blacklight/ReleaseRemover.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function removeByCriteria(array $arguments): bool|string

if ($this->echoCLI) {
$this->colorCLI->headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ').$this->deletedCount.' release(s). This script ran for ');
$this->colorCLI->header(now()->diffInSeconds($timeStart).' seconds', true);
$this->colorCLI->header(now()->diffInSeconds($timeStart, true).' seconds', true);
}

return true;
Expand Down Expand Up @@ -239,7 +239,7 @@ public function removeCrap(bool $delete, int|string $time, string $type = '', in

if ($this->echoCLI) {
$this->colorCLI->headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ').$this->deletedCount.' release(s). This script ran for ');
$this->colorCLI->header(now()->diffInSeconds($timeStart).' seconds', true);
$this->colorCLI->header(now()->diffInSeconds($timeStart, true).' seconds', true);
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion Blacklight/libraries/Forking.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ private function safeBackfill(): void
if ($backfill_days === 1) {
$backfilldays = 'g.backfill_target';
} elseif ($backfill_days === 2) {
$backfilldays = now()->diffInDays(Carbon::createFromFormat('Y-m-d', Settings::settingValue('..safebackfilldate')));
$backfilldays = now()->diffInDays(Carbon::createFromFormat('Y-m-d', Settings::settingValue('..safebackfilldate')), true);
}

$data = DB::select(
Expand Down
18 changes: 9 additions & 9 deletions Blacklight/processing/ProcessReleases.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function processIncompleteCollections($groupID): void
}
$count = $countQuery->count('id');

$totalTime = now()->diffInSeconds($startTime);
$totalTime = now()->diffInSeconds($startTime, true);

$this->colorCLI->primary(
($count ?? 0).' collections were found to be complete. Time: '.
Expand Down Expand Up @@ -282,7 +282,7 @@ public function processCollectionSizes($groupID): void
$checked.' collections set to filecheck = 3(size calculated)',
true
);
$totalTime = now()->diffInSeconds($startTime);
$totalTime = now()->diffInSeconds($startTime, true);
$this->colorCLI->primary($totalTime.Str::plural(' second', $totalTime), true);
}
}, 10);
Expand Down Expand Up @@ -366,7 +366,7 @@ public function deleteUnwantedCollections($groupID): void
}
}

$totalTime = now()->diffInSeconds($startTime);
$totalTime = now()->diffInSeconds($startTime, true);

if ($this->echoCLI) {
$this->colorCLI->primary('Deleted '.($minSizeDeleted + $maxSizeDeleted + $minFilesDeleted).' collections: '.PHP_EOL.$minSizeDeleted.' smaller than, '.$maxSizeDeleted.' bigger than, '.$minFilesDeleted.' with less files than site/group settings in: '.$totalTime.Str::plural(' second', $totalTime), true);
Expand Down Expand Up @@ -535,7 +535,7 @@ public function createReleases(int|string $groupID): array
}
}

$totalTime = now()->diffInSeconds($startTime);
$totalTime = now()->diffInSeconds($startTime, true);

if ($this->echoCLI) {
$this->colorCLI->primary(
Expand Down Expand Up @@ -587,7 +587,7 @@ public function createNZBs(int|string $groupID): int
}
}

$totalTime = now()->diffInSeconds($startTime);
$totalTime = now()->diffInSeconds($startTime, true);

if ($this->echoCLI) {
$this->colorCLI->primary(
Expand Down Expand Up @@ -625,7 +625,7 @@ public function categorizeReleases(int $categorize, int|string $groupID = ''): v
$groupID
);

$totalTime = now()->diffInSeconds($startTime);
$totalTime = now()->diffInSeconds($startTime, true);

if ($this->echoCLI) {
$this->colorCLI->primary($totalTime.Str::plural(' second', $totalTime));
Expand Down Expand Up @@ -682,7 +682,7 @@ public function deleteCollections($groupID): void
}
$firstQuery = $fourthQuery = now();

$totalTime = $firstQuery->diffInSeconds($startTime);
$totalTime = $firstQuery->diffInSeconds($startTime, true);

if ($this->echoCLI) {
$this->colorCLI->primary(
Expand Down Expand Up @@ -729,8 +729,8 @@ public function deleteCollections($groupID): void
}
$deletedCount += $deleted;

$colDelTime = now()->diffInSeconds($fourthQuery);
$totalTime = $fourthQuery->diffInSeconds($startTime);
$colDelTime = now()->diffInSeconds($fourthQuery, true);
$totalTime = $fourthQuery->diffInSeconds($startTime, true);

if ($this->echoCLI) {
$this->colorCLI->primary('Finished deleting '.$deleted.' collections missed after NZB creation in '.$colDelTime.Str::plural(' second', $colDelTime).PHP_EOL.'Removed '.number_format($deletedCount).' parts/binaries/collection rows in '.$totalTime.Str::plural(' second', $totalTime), true);
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/CleanNZB.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CleanNZB extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
// Check if any options are false
if (! $this->option('notindb') && ! $this->option('notondisk')) {
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/ImportNzbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ImportNzbs extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
if ($this->option('folder')) {
if ($this->option('filename')) {
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/RecategorizeReleases.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class RecategorizeReleases extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
$countQuery = Release::query();
if ($this->option('misc')) {
Expand Down
48 changes: 0 additions & 48 deletions app/Console/Kernel.php

This file was deleted.

27 changes: 27 additions & 0 deletions app/Http/Controllers/Auth/VerifyEmailController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Auth\Events\Verified;
use Illuminate\Foundation\Auth\EmailVerificationRequest;
use Illuminate\Http\RedirectResponse;

class VerifyEmailController extends Controller
{
/**
* Mark the authenticated user's email address as verified.
*/
public function __invoke(EmailVerificationRequest $request): RedirectResponse
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
}

if ($request->user()->markEmailAsVerified()) {
event(new Verified($request->user()));
}

return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
}
}
Loading

0 comments on commit e0f5174

Please sign in to comment.