Skip to content

Commit

Permalink
added new setAppInitProgress function (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigcat88 authored Jul 10, 2024
1 parent d9a03f6 commit 1ac1d66
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion docs/tech_details/InstallationFlow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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**.
Expand Down
17 changes: 13 additions & 4 deletions lib/Controller/OCSApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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).
Expand Down
1 change: 1 addition & 0 deletions lib/Service/ExAppApiScopeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1ac1d66

Please sign in to comment.