Skip to content

Commit 658edbf

Browse files
committed
feat(ocm): handle /well-known/ocm
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
1 parent e3edf43 commit 658edbf

4 files changed

Lines changed: 35 additions & 0 deletions

File tree

core/AppInfo/Application.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use OC\Core\Listener\BeforeTemplateRenderedListener;
2323
use OC\Core\Listener\PasswordUpdatedListener;
2424
use OC\Core\Notification\CoreNotifier;
25+
use OC\OCM\OCMDiscoveryHandler;
2526
use OC\TagManager;
2627
use OCP\AppFramework\App;
2728
use OCP\AppFramework\Bootstrap\IBootContext;
@@ -85,6 +86,7 @@ public function register(IRegistrationContext $context): void {
8586
// config lexicon
8687
$context->registerConfigLexicon(ConfigLexicon::class);
8788

89+
$context->registerWellKnownHandler(OCMDiscoveryHandler::class);
8890
$context->registerCapability(Capabilities::class);
8991
}
9092

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,7 @@
18731873
'OC\\Notification\\Notification' => $baseDir . '/lib/private/Notification/Notification.php',
18741874
'OC\\OCM\\Model\\OCMProvider' => $baseDir . '/lib/private/OCM/Model/OCMProvider.php',
18751875
'OC\\OCM\\Model\\OCMResource' => $baseDir . '/lib/private/OCM/Model/OCMResource.php',
1876+
'OC\\OCM\\OCMDiscoveryHandler' => $baseDir . '/lib/private/OCM/OCMDiscoveryHandler.php',
18761877
'OC\\OCM\\OCMDiscoveryService' => $baseDir . '/lib/private/OCM/OCMDiscoveryService.php',
18771878
'OC\\OCM\\OCMSignatoryManager' => $baseDir . '/lib/private/OCM/OCMSignatoryManager.php',
18781879
'OC\\OCS\\ApiHelper' => $baseDir . '/lib/private/OCS/ApiHelper.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,6 +1922,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
19221922
'OC\\Notification\\Notification' => __DIR__ . '/../../..' . '/lib/private/Notification/Notification.php',
19231923
'OC\\OCM\\Model\\OCMProvider' => __DIR__ . '/../../..' . '/lib/private/OCM/Model/OCMProvider.php',
19241924
'OC\\OCM\\Model\\OCMResource' => __DIR__ . '/../../..' . '/lib/private/OCM/Model/OCMResource.php',
1925+
'OC\\OCM\\OCMDiscoveryHandler' => __DIR__ . '/../../..' . '/lib/private/OCM/OCMDiscoveryHandler.php',
19251926
'OC\\OCM\\OCMDiscoveryService' => __DIR__ . '/../../..' . '/lib/private/OCM/OCMDiscoveryService.php',
19261927
'OC\\OCM\\OCMSignatoryManager' => __DIR__ . '/../../..' . '/lib/private/OCM/OCMSignatoryManager.php',
19271928
'OC\\OCS\\ApiHelper' => __DIR__ . '/../../..' . '/lib/private/OCS/ApiHelper.php',
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OC\OCM;
11+
12+
use OCP\AppFramework\Http\JSONResponse;
13+
use OCP\Http\WellKnown\GenericResponse;
14+
use OCP\Http\WellKnown\IHandler;
15+
use OCP\Http\WellKnown\IRequestContext;
16+
use OCP\Http\WellKnown\IResponse;
17+
18+
class OCMDiscoveryHandler implements IHandler {
19+
public function __construct(
20+
private readonly OCMDiscoveryService $discoveryService,
21+
) {
22+
}
23+
24+
public function handle(string $service, IRequestContext $context, ?IResponse $previousResponse): ?IResponse {
25+
if ($service !== 'ocm') {
26+
return $previousResponse;
27+
}
28+
29+
return new GenericResponse(new JsonResponse($this->discoveryService->getLocalOCMProvider()));
30+
}
31+
}

0 commit comments

Comments
 (0)