Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c9f534f
Convert `optional()` to nullsafe operator
laravel-shift May 7, 2023
03436b6
Convert route options to fluent methods
laravel-shift May 7, 2023
99f8e44
Remove explicit call to register policies
laravel-shift May 7, 2023
9f27af0
Shift core files
laravel-shift May 7, 2023
f223af2
Shift config files
laravel-shift May 7, 2023
a2bf1a1
Default config files
laravel-shift May 7, 2023
225e72b
Bump Laravel dependencies
laravel-shift May 7, 2023
ee6f384
Prepare test suite for PHPUnit 10
laravel-shift May 7, 2023
ac5ef6a
Adopt anonymous migrations
laravel-shift May 7, 2023
7b9a3b0
Rename `password_resets` table
laravel-shift May 7, 2023
1c226ac
Update method signatures for Laravel contracts
laravel-shift May 7, 2023
effc3bd
Add type hints for Laravel 10
laravel-shift May 7, 2023
470ac78
Add type hints from DocBlocks
laravel-shift May 7, 2023
2375f90
Remove redundant typing from DocBlocks
laravel-shift May 7, 2023
66c44bc
Shift cleanup
laravel-shift May 7, 2023
faf74a5
void function can't return data
alexjustesen May 7, 2023
f67fbbf
refactored cron validation to implement validationrule
alexjustesen May 7, 2023
8a243cf
refactored notifications page to return early
alexjustesen May 7, 2023
daedb12
published updated local env docker files
alexjustesen May 7, 2023
cb4e0f0
refactored telegram test notification
alexjustesen May 7, 2023
8eaf4a3
updated composer dependencies
alexjustesen May 7, 2023
10de1c3
code quality
alexjustesen May 7, 2023
71cd08c
me
alexjustesen May 7, 2023
14c337a
removed imap
alexjustesen May 7, 2023
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

.env
.env.backup
.phpunit.result.cache
/.phpunit.cache
Homestead.json
Homestead.yaml
auth.json
Expand Down
99 changes: 66 additions & 33 deletions .phpstorm.meta.php

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":1,"defects":[],"times":{"Tests\\Unit\\ExampleTest::test_that_true_is_true":0.001,"Tests\\Feature\\ExampleTest::test_the_application_returns_a_successful_response":0.125}}
722 changes: 589 additions & 133 deletions _ide_helper.php

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions app/Console/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ class InstallCommand extends Command

/**
* Execute the console command.
*
* @return int
*/
public function handle()
public function handle(): int
{
if (! $this->option('force')) {
$this->newLine(2);
Expand Down
4 changes: 1 addition & 3 deletions app/Console/Commands/RunSpeedtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ class RunSpeedtest extends Command

/**
* Execute the console command.
*
* @return int
*/
public function handle()
public function handle(): int
{
$speedtest = [];

Expand Down
12 changes: 5 additions & 7 deletions app/Console/Commands/TestInfluxDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ class TestInfluxDB extends Command

/**
* Execute the console command.
*
* @return int
*/
public function handle(InfluxDbSettings $settings)
public function handle(InfluxDbSettings $settings): int
{
$influxdb = [
'enabled' => $settings->v2_enabled,
'url' => optional($settings)->v2_url,
'org' => optional($settings)->v2_org,
'bucket' => optional($settings)->v2_bucket,
'token' => optional($settings)->v2_token,
'url' => $settings?->v2_url,
'org' => $settings?->v2_org,
'bucket' => $settings?->v2_bucket,
'token' => $settings?->v2_token,
];

if ($influxdb['enabled'] == true) {
Expand Down
8 changes: 2 additions & 6 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @return void
*/
protected function schedule(Schedule $schedule)
protected function schedule(Schedule $schedule): void
{
$schedule->job(new SearchForSpeedtests())->everyMinute();

Expand All @@ -24,10 +22,8 @@ protected function schedule(Schedule $schedule)

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
protected function commands(): void
{
$this->load(__DIR__.'/Commands');

Expand Down
24 changes: 2 additions & 22 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,7 @@
class Handler extends ExceptionHandler
{
/**
* A list of exception types with their corresponding custom log levels.
*
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//
];

/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed to the session on validation exceptions.
* The list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
Expand All @@ -38,10 +20,8 @@ class Handler extends ExceptionHandler

/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
public function register(): void
{
$this->reportable(function (Throwable $e) {
//
Expand Down
4 changes: 2 additions & 2 deletions app/Filament/Pages/Settings/GeneralPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Filament\Pages\Settings;

use App\Rules\ValidCronExpression;
use App\Rules\Cron;
use App\Settings\GeneralSettings;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Section;
Expand Down Expand Up @@ -75,7 +75,7 @@ protected function getFormSchema(): array
Section::make('Speedtest Settings')
->schema([
TextInput::make('speedtest_schedule')
->rules([new ValidCronExpression()])
->rules([new Cron()])
->helperText('Leave empty to disable the schedule. You can also use the cron expression generator [HERE](https://crontab.cronhub.io/) to help you make schedules.')
->nullable()
->columnSpan(1),
Expand Down
69 changes: 40 additions & 29 deletions app/Filament/Pages/Settings/NotificationPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use App\Forms\Components\TestMailNotification;
use App\Forms\Components\TestTelegramNotification;
use App\Mail\Test;
use App\Notifications\Telegram\TestNotification as TelegramTestNotification;
use App\Settings\GeneralSettings;
use App\Settings\NotificationSettings;
use App\Telegram\TelegramNotification;
use Closure;
use Filament\Forms\Components\Card;
use Filament\Forms\Components\Fieldset;
Expand All @@ -21,6 +21,7 @@
use Filament\Notifications\Notification;
use Filament\Pages\SettingsPage;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Notification as FacadesNotification;

class NotificationPage extends SettingsPage
{
Expand Down Expand Up @@ -179,7 +180,7 @@ protected function getFormSchema(): array
];
}

public function sendTestDatabaseNotification()
public function sendTestDatabaseNotification(): void
{
$recipient = auth()->user();

Expand All @@ -198,55 +199,65 @@ public function sendTestDatabaseNotification()
->send();
}

public function sendTestMailNotification()
public function sendTestMailNotification(): void
{
$notificationSettings = new (NotificationSettings::class);

if (! empty($notificationSettings->mail_recipients)) {
foreach ($notificationSettings->mail_recipients as $recipient) {
Mail::to($recipient)
->send(new Test());
}

Notification::make()
->title('Test mail notification sent.')
->success()
->send();
} else {
if (blank($notificationSettings->mail_recipients)) {
Notification::make()
->title('You need to add recipients to receive mail notifications.')
->title('You need to add mail recipients.')
->body('Make sure to click "Save changes" before testing mail notifications.')
->warning()
->send();

return;
}

foreach ($notificationSettings->mail_recipients as $recipient) {
Mail::to($recipient)
->send(new Test());
}

Notification::make()
->title('Test mail notification sent.')
->success()
->send();
}

public function sendTestTelegramNotification()
public function sendTestTelegramNotification(): void
{
$notificationSettings = new (NotificationSettings::class);

$bot = config('telegram.bot');

if (blank($bot)) {
Notification::make()
->title('First you need to add \'TELEGRAM_BOT_TOKEN\' on your .env file or add it as environment variable')
->warning()
->title('No Telegram bot provided.')
->body('You need to add "TELEGRAM_BOT_TOKEN" in your .env file or add it as environment variable')
->danger()
->send();

return;
}
if (! empty($notificationSettings->telegram_recipients)) {
foreach ($notificationSettings->telegram_recipients as $recipient) {
\Illuminate\Support\Facades\Notification::route('telegram_chat_id', $recipient['telegram_chat_id'])
->notify(new TelegramNotification('Test notification channel *telegram*'));
}

if (blank($notificationSettings->telegram_recipients)) {
Notification::make()
->title('Test Telegram notification sent.')
->success()
->send();
} else {
Notification::make()
->title('You need to add recipients to receive Telegram notifications.')
->title('You need to add Telegram recipients.')
->body('Make sure to click "Save changes" before testing Telegram notifications.')
->warning()
->send();

return;
}

foreach ($notificationSettings->telegram_recipients as $recipient) {
FacadesNotification::route('telegram_chat_id', $recipient['telegram_chat_id'])
->notify(new TelegramTestNotification);
}

Notification::make()
->title('Test Telegram notification sent.')
->success()
->send();
}
}
2 changes: 1 addition & 1 deletion app/Filament/Resources/ResultResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static function table(Table $table): Table
Action::make('view result')
->label('View on Speedtest.net')
->icon('heroicon-o-link')
->url(fn (Result $record): string|null => optional($record)->url)
->url(fn (Result $record): string|null => $record?->url)
->hidden(fn (Result $record): bool => ! $record->is_successful)
->openUrlInNewTab(),
Tables\Actions\ViewAction::make(),
Expand Down
5 changes: 2 additions & 3 deletions app/Http/Controllers/API/Speedtest/GetLatestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

use App\Http\Controllers\Controller;
use App\Models\Result;
use Illuminate\Http\JsonResponse;

class GetLatestController extends Controller
{
/**
* Handle the incoming request.
*
* @return \Illuminate\Http\Response
*/
public function __invoke()
public function __invoke(): JsonResponse
{
$latest = Result::query()
->latest()
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
use AuthorizesRequests, ValidatesRequests;
}
8 changes: 4 additions & 4 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ class Kernel extends HttpKernel

'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];

/**
* The application's route middleware.
* The application's middleware aliases.
*
* These middleware may be assigned to groups or used individually.
* Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
*
* @var array<string, class-string|string>
*/
protected $routeMiddleware = [
protected $middlewareAliases = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
Expand Down
6 changes: 2 additions & 4 deletions app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Http\Request;

class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
protected function redirectTo(Request $request): ?string
{
if (! $request->expectsJson()) {
return route('admin/login');
Expand Down
5 changes: 2 additions & 3 deletions app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;

class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @param string|null ...$guards
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next, ...$guards)
public function handle(Request $request, Closure $next, string ...$guards): Response
{
$guards = empty($guards) ? [null] : $guards;

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/TrustHosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TrustHosts extends Middleware
*
* @return array<int, string|null>
*/
public function hosts()
public function hosts(): array
{
return [
$this->allSubdomainsOfApplicationUrl(),
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Middleware/ValidateSignature.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
class ValidateSignature extends Middleware
{
/**
* The names of the parameters that should be ignored.
* The names of the query string parameters that should be ignored.
*
* @var array<int, string>
*/
protected $ignore = [
protected $except = [
// 'fbclid',
// 'utm_campaign',
// 'utm_content',
Expand Down
Loading