diff --git a/CHANGELOG.md b/CHANGELOG.md index 83e3cbbb..56859925 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [2.7.1 - 2024-07-xx] +### Added + +- New OCS API endpoint to setAppInitProgress. The old one is marked as deprecated. #319 + ### Fixed - Allow ExApps management disable and remove actions if default Deploy daemon is not accessible. #314 -- Fixed Deploy daemon avilability check using ping timeout set to 3s. #314 +- Fixed Deploy daemon availability check using ping timeout set to 3s. #314 - Fix Test Deploy `image_pull` and `init` steps status update. #315 ## [2.7.0 - 2024-07-01] diff --git a/appinfo/routes.php b/appinfo/routes.php index 0840043b..328b0425 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -58,7 +58,8 @@ ['name' => 'OCSApi#log', 'url' => '/api/v1/log', 'verb' => 'POST'], ['name' => 'OCSApi#getNCUsersList', 'url' => '/api/v1/users', 'verb' => 'GET'], - ['name' => 'OCSApi#setAppInitProgress', 'url' => '/apps/status/{appId}', 'verb' => 'PUT'], + ['name' => 'OCSApi#setAppInitProgressDeprecated', 'url' => '/apps/status/{appId}', 'verb' => 'PUT'], + ['name' => 'OCSApi#setAppInitProgress', 'url' => '/ex-app/status', 'verb' => 'PUT'], ['name' => 'OCSApi#getEnabledState', 'url' => '/ex-app/state', 'verb' => 'GET'], // ExApps diff --git a/docs/tech_details/InstallationFlow.rst b/docs/tech_details/InstallationFlow.rst index 1c0810f8..c016dd84 100644 --- a/docs/tech_details/InstallationFlow.rst +++ b/docs/tech_details/InstallationFlow.rst @@ -52,7 +52,11 @@ AppAPI will get 404 or 501 error on it's request, and consider that initializati In case you want to implement "/init" endpoint, your application should: 1. In "/init" handler: Response with empty JSON on AppAPI call. -2. In background job: Send an ``OCS request`` to ``/ocs/v1.php/apps/app_api/apps/status/$APP_ID`` with the progress value. +2. In background job: Send an ``OCS request`` to ``PUT /ocs/v1.php/apps/app_api/ex-app/status`` with the progress value. + +.. warning:: + + ``PUT /ocs/v1.php/apps/app_api/apps/status/$APP_ID`` is deprecated and will be removed in the future. Possible values for **progress** are integers from 1 to 100; after receiving the value 100, the **application is considered initialized and ready to work**. diff --git a/lib/Controller/OCSApiController.php b/lib/Controller/OCSApiController.php index e39011b2..ef021c8f 100644 --- a/lib/Controller/OCSApiController.php +++ b/lib/Controller/OCSApiController.php @@ -60,13 +60,10 @@ public function getNCUsersList(): DataResponse { return new DataResponse($this->exAppService->getNCUsersList(), Http::STATUS_OK); } - /** - * Get ExApp status, that required during initialization step with progress information - */ #[AppAPIAuth] #[PublicPage] #[NoCSRFRequired] - public function setAppInitProgress(string $appId, int $progress, string $error = ''): DataResponse { + public function setAppInitProgressDeprecated(string $appId, int $progress, string $error = ''): DataResponse { $exApp = $this->exAppService->getExApp($appId); if (!$exApp) { return new DataResponse([], Http::STATUS_NOT_FOUND); @@ -75,6 +72,18 @@ public function setAppInitProgress(string $appId, int $progress, string $error = return new DataResponse(); } + #[AppAPIAuth] + #[PublicPage] + #[NoCSRFRequired] + public function setAppInitProgress(int $progress, string $error = ''): DataResponse { + $exApp = $this->exAppService->getExApp($this->request->getHeader('EX-APP-ID')); + if (!$exApp) { + return new DataResponse([], Http::STATUS_NOT_FOUND); + } + $this->service->setAppInitProgress($exApp, $progress, $error); + return new DataResponse(); + } + /** * Retrieves the enabled status of an ExApp (0 for disabled, 1 for enabled). diff --git a/lib/Service/ExAppApiScopeService.php b/lib/Service/ExAppApiScopeService.php index 5d33b210..65b5d70f 100644 --- a/lib/Service/ExAppApiScopeService.php +++ b/lib/Service/ExAppApiScopeService.php @@ -39,6 +39,7 @@ public function __construct( // AppAPI internal scopes ['api_route' => '/apps/app_api/apps/status', 'scope_group' => 1, 'name' => 'BASIC', 'user_check' => 0], + ['api_route' => '/apps/app_api/ex-app/status', 'scope_group' => 1, 'name' => 'BASIC', 'user_check' => 0], ['api_route' => '/apps/app_api/ex-app/state', 'scope_group' => 1, 'name' => 'BASIC', 'user_check' => 0], // Cloud scopes