Skip to content

Commit d7214d0

Browse files
authored
Merge pull request #612 from nextcloud/feat/route/nc-absolute-url
feat(new-route): added endpoint to call NC getAbsoluteURL
2 parents 990f69b + 493f142 commit d7214d0

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

appinfo/routes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
['name' => 'OCSApi#setAppInitProgressDeprecated', 'url' => '/apps/status/{appId}', 'verb' => 'PUT'],
7474
['name' => 'OCSApi#setAppInitProgress', 'url' => '/ex-app/status', 'verb' => 'PUT'],
7575
['name' => 'OCSApi#getEnabledState', 'url' => '/ex-app/state', 'verb' => 'GET'],
76+
['name' => 'OCSApi#getNextcloudAbsoluteUrl', 'url' => '/api/v1/info/nextcloud_url/absolute', 'verb' => 'GET'],
7677

7778
// ExApps
7879
['name' => 'OCSExApp#getNextcloudUrl', 'url' => '/api/v1/info/nextcloud_url', 'verb' => 'GET'],

lib/Controller/OCSApiController.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
use OCA\AppAPI\AppInfo\Application;
1313
use OCA\AppAPI\Attribute\AppAPIAuth;
1414
use OCA\AppAPI\Service\AppAPIService;
15-
1615
use OCA\AppAPI\Service\ExAppService;
16+
1717
use OCP\AppFramework\Http;
1818
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
1919
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
@@ -22,6 +22,7 @@
2222
use OCP\AppFramework\OCS\OCSBadRequestException;
2323
use OCP\AppFramework\OCSController;
2424
use OCP\IRequest;
25+
use OCP\IURLGenerator;
2526
use Psr\Log\InvalidArgumentException;
2627
use Psr\Log\LoggerInterface;
2728

@@ -33,6 +34,7 @@ public function __construct(
3334
private readonly LoggerInterface $logger,
3435
private readonly AppAPIService $service,
3536
private readonly ExAppService $exAppService,
37+
private readonly IURLGenerator $urlGenerator,
3638
) {
3739
parent::__construct(Application::APP_ID, $request);
3840

@@ -89,7 +91,6 @@ public function setAppInitProgress(int $progress, string $error = ''): DataRespo
8991
return new DataResponse();
9092
}
9193

92-
9394
/**
9495
* Retrieves the enabled status of an ExApp (0 for disabled, 1 for enabled).
9596
* Note: This endpoint is accessible even if the ExApp itself is disabled.
@@ -106,4 +107,13 @@ public function getEnabledState(): DataResponse {
106107
}
107108
return new DataResponse($exApp->getEnabled());
108109
}
110+
111+
#[AppAPIAuth]
112+
#[PublicPage]
113+
#[NoCSRFRequired]
114+
public function getNextcloudAbsoluteUrl(string $url): DataResponse {
115+
return new DataResponse([
116+
'absolute_url' => $this->urlGenerator->getAbsoluteURL($url),
117+
], Http::STATUS_OK);
118+
}
109119
}

0 commit comments

Comments
 (0)