- HttpTask: Laravel Http facade with SSL enabled, retry, timeout - ValidateTokenTask: token check via auth.db-nica.ru - RefreshTokenTask: token refresh via db-nica.ru - FilesystemTask: path traversal protection, blocked extensions (PHP/ASP/etc) - AuthenticateAction: OAuth2 code→token exchange - CheckAccessAction: token validation + filesystem writability check - CheckVersionAction: version comparison against remote API - UpdateCoreAction: ZIP download, Zip Slip protection, atomic sync with rollback - VikonController: thin controller, 7 endpoints with Session-based token storage - Routes: access-check, dashboard.auth, throttle:30,1 middleware - Vue 3 Composition API frontend with progress bar - Config: all secrets in .env via config/vikon.php - vikon_core kept as fallback (not deleted)
37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Containers\VikonIntegration\Actions;
|
|
|
|
use App\Containers\VikonIntegration\Tasks\HttpTask;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class CheckVersionAction
|
|
{
|
|
public function __construct(
|
|
private readonly HttpTask $http,
|
|
private readonly string $currentVersion,
|
|
) {}
|
|
|
|
public function run(string $accessToken): array
|
|
{
|
|
try {
|
|
$response = $this->http->getWithToken('pull_updates/getLatestVersion', $accessToken);
|
|
$body = $response->json();
|
|
$latest = $body['version'] ?? null;
|
|
return [
|
|
'current_version' => $this->currentVersion,
|
|
'latest_version' => $latest,
|
|
'has_update' => $latest && version_compare($latest, $this->currentVersion, '>'),
|
|
];
|
|
} catch (\Throwable $e) {
|
|
Log::warning('Version check failed', ['error' => $e->getMessage()]);
|
|
return [
|
|
'current_version' => $this->currentVersion,
|
|
'latest_version' => null,
|
|
'has_update' => false,
|
|
'error' => 'Не удалось проверить обновления',
|
|
];
|
|
}
|
|
}
|
|
}
|