Files
ntspi-app/app/Containers/VikonIntegration/Actions/CheckVersionAction.php
T
F4ilji 93721fc5ae fix(vikon): use correct VIKON API endpoints
- CheckAccessAction: pull_updates/assist/getModulesTreeAsync (not checkAccessJson)
- CheckVersionAction: pull_updates/assist/getUpdateVersionJson (not getLatestVersion)

These are the actual endpoints used by the original vikon_core update.js
2026-07-04 13:57:17 +05:00

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/assist/getUpdateVersionJson', $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' => 'Не удалось проверить обновления',
];
}
}
}