2024-03-01 13:04:29 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Listeners;
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Events\MaintenanceModeDisabled as EventsMaintenanceModeDisabled;
|
|
|
|
use Illuminate\Support\Facades\Request;
|
|
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
|
|
|
|
|
|
|
|
class MaintenanceModeDisabledNotification
|
|
|
|
{
|
2024-06-19 06:59:46 +00:00
|
|
|
public function __construct() {}
|
2024-03-01 13:04:29 +00:00
|
|
|
|
|
|
|
public function handle(EventsMaintenanceModeDisabled $event): void
|
|
|
|
{
|
|
|
|
ray('Maintenance mode disabled!');
|
|
|
|
$files = Storage::disk('webhooks-during-maintenance')->files();
|
|
|
|
$files = collect($files);
|
|
|
|
$files = $files->sort();
|
|
|
|
foreach ($files as $file) {
|
|
|
|
$content = Storage::disk('webhooks-during-maintenance')->get($file);
|
|
|
|
$data = json_decode($content, true);
|
|
|
|
$symfonyRequest = new SymfonyRequest(
|
|
|
|
$data['query'],
|
|
|
|
$data['request'],
|
|
|
|
$data['attributes'],
|
|
|
|
$data['cookies'],
|
|
|
|
$data['files'],
|
|
|
|
$data['server'],
|
|
|
|
$data['content']
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach ($data['headers'] as $key => $value) {
|
|
|
|
$symfonyRequest->headers->set($key, $value);
|
|
|
|
}
|
|
|
|
$request = Request::createFromBase($symfonyRequest);
|
|
|
|
$endpoint = str($file)->after('_')->beforeLast('_')->value();
|
2024-06-10 20:43:34 +00:00
|
|
|
$class = "App\Http\Controllers\Webhook\\".ucfirst(str($endpoint)->before('::')->value());
|
2024-03-01 13:04:29 +00:00
|
|
|
$method = str($endpoint)->after('::')->value();
|
|
|
|
try {
|
2024-07-24 12:27:21 +00:00
|
|
|
$instance = new $class;
|
2024-03-01 13:04:29 +00:00
|
|
|
$instance->$method($request);
|
|
|
|
} catch (\Throwable $th) {
|
|
|
|
ray($th);
|
|
|
|
} finally {
|
|
|
|
Storage::disk('webhooks-during-maintenance')->delete($file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|