From 93721fc5ae7acbf5b6f6a1fd8c42dc4cd2d1cd38 Mon Sep 17 00:00:00 2001 From: F4ilji Date: Sat, 4 Jul 2026 13:57:17 +0500 Subject: [PATCH] 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 --- .../Actions/CheckAccessAction.php | 32 ++++++++++++++++--- .../Actions/CheckVersionAction.php | 2 +- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/app/Containers/VikonIntegration/Actions/CheckAccessAction.php b/app/Containers/VikonIntegration/Actions/CheckAccessAction.php index b634319..8b3479b 100644 --- a/app/Containers/VikonIntegration/Actions/CheckAccessAction.php +++ b/app/Containers/VikonIntegration/Actions/CheckAccessAction.php @@ -21,15 +21,37 @@ class CheckAccessAction return ['has_access' => false, 'error' => 'Токен недействителен. Выполните повторную авторизацию.']; } - $nonWritable = $this->findNonWritable($this->publicPath); - if (!empty($nonWritable)) { + try { + $response = $this->http->getWithToken('pull_updates/assist/getModulesTreeAsync', $accessToken); + $body = $response->json(); + + if (!isset($body['tree_access'])) { + return [ + 'has_access' => false, + 'error' => 'Нет прав на обновление. Обратитесь к администратору VIKON.', + ]; + } + + $nonWritable = $this->findNonWritable($this->publicPath); + if (!empty($nonWritable)) { + return [ + 'has_access' => false, + 'error' => 'Нет прав на запись: ' . implode(', ', array_slice($nonWritable, 0, 3)), + ]; + } + + return [ + 'has_access' => true, + 'error' => null, + 'modules_tree' => $body['tree_access'], + ]; + } catch (\Throwable $e) { + Log::error('Vikon access check failed', ['error' => $e->getMessage()]); return [ 'has_access' => false, - 'error' => 'Нет прав на запись: ' . implode(', ', array_slice($nonWritable, 0, 3)), + 'error' => 'Не удалось проверить права: ' . $e->getMessage(), ]; } - - return ['has_access' => true, 'error' => null]; } private function findNonWritable(string $path, int $depth = 0): array diff --git a/app/Containers/VikonIntegration/Actions/CheckVersionAction.php b/app/Containers/VikonIntegration/Actions/CheckVersionAction.php index 7b084b5..ee8c9c4 100644 --- a/app/Containers/VikonIntegration/Actions/CheckVersionAction.php +++ b/app/Containers/VikonIntegration/Actions/CheckVersionAction.php @@ -15,7 +15,7 @@ class CheckVersionAction public function run(string $accessToken): array { try { - $response = $this->http->getWithToken('pull_updates/getLatestVersion', $accessToken); + $response = $this->http->getWithToken('pull_updates/assist/getUpdateVersionJson', $accessToken); $body = $response->json(); $latest = $body['version'] ?? null; return [