Skip to content

Commit aae372b

Browse files
authored
feat: add nextcloud url helper info endpoint to get instance base_url (#383)
Added miscellaneous OCS method to get current Nextcloud instance base_url. <img width="883" alt="image" src="https://github.com/user-attachments/assets/42b98354-eabd-4fd4-b75b-fed6e49dd627"> --------- Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
1 parent f0a44bf commit aae372b

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## [3.2.0 - 2024-09-09]
8+
## [3.2.0 - 2024-09-10]
99

1010
### Added
1111

1212
- ExAppProxy: added bruteforce protection option for ExApp routes. #368
13+
- ExAppOCS: added miscellaneous method to get Nextcloud instance base URL. #383
1314

1415
### Changed
1516

appinfo/routes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
['name' => 'OCSApi#getEnabledState', 'url' => '/ex-app/state', 'verb' => 'GET'],
6565

6666
// ExApps
67+
['name' => 'OCSExApp#getNextcloudUrl', 'url' => '/api/v1/info/nextcloud_url', 'verb' => 'GET'],
6768
['name' => 'OCSExApp#getExAppsList', 'url' => '/api/v1/ex-app/{list}', 'verb' => 'GET'],
6869
['name' => 'OCSExApp#getExApp', 'url' => '/api/v1/ex-app/info/{appId}', 'verb' => 'GET'],
6970

docs/tech_details/api/exapp.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,24 @@ Response data
5959

6060
Returns HTTP 200 on success, HTTP 404 - on error.
6161

62+
Get Nextcloud URL
63+
^^^^^^^^^^^^^^^^^
64+
65+
It might be necessary for ExApp to know (or update) the Nextcloud URL.
66+
67+
OCS endpoint: ``GET /apps/app_api/api/v1/info/nextcloud_url``
68+
69+
Response data
70+
*************
71+
72+
Returns the base URL of the Nextcloud instance:
73+
74+
.. code-block:: json
75+
76+
{
77+
"base_url": "http(s)://nextcloud.example.com"
78+
}
79+
6280
6381
Make Requests to ExApps
6482
^^^^^^^^^^^^^^^^^^^^^^^

lib/Controller/OCSExAppController.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use OCP\AppFramework\OCS\OCSBadRequestException;
1515
use OCP\AppFramework\OCSController;
1616
use OCP\IRequest;
17+
use OCP\IURLGenerator;
1718

1819
class OCSExAppController extends OCSController {
1920
protected $request;
@@ -22,6 +23,7 @@ public function __construct(
2223
IRequest $request,
2324
private readonly AppAPIService $service,
2425
private readonly ExAppService $exAppService,
26+
private readonly IURLGenerator $urlGenerator,
2527
) {
2628
parent::__construct(Application::APP_ID, $request);
2729

@@ -45,6 +47,13 @@ public function getExApp(string $appId): DataResponse {
4547
return new DataResponse($this->exAppService->formatExAppInfo($exApp), Http::STATUS_OK);
4648
}
4749

50+
#[NoCSRFRequired]
51+
public function getNextcloudUrl(): DataResponse {
52+
return new DataResponse([
53+
'base_url' => $this->urlGenerator->getBaseUrl(),
54+
], Http::STATUS_OK);
55+
}
56+
4857
/**
4958
* @throws OCSBadRequestException
5059
*/

0 commit comments

Comments
 (0)