Skip to content

Commit e456f11

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

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
@@ -1871,6 +1871,7 @@
18711871
'OC\\Notification\\Notification' => $baseDir . '/lib/private/Notification/Notification.php',
18721872
'OC\\OCM\\Model\\OCMProvider' => $baseDir . '/lib/private/OCM/Model/OCMProvider.php',
18731873
'OC\\OCM\\Model\\OCMResource' => $baseDir . '/lib/private/OCM/Model/OCMResource.php',
1874+
'OC\\OCM\\OCMDiscoveryHandler' => $baseDir . '/lib/private/OCM/OCMDiscoveryHandler.php',
18741875
'OC\\OCM\\OCMDiscoveryService' => $baseDir . '/lib/private/OCM/OCMDiscoveryService.php',
18751876
'OC\\OCM\\OCMSignatoryManager' => $baseDir . '/lib/private/OCM/OCMSignatoryManager.php',
18761877
'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
@@ -1912,6 +1912,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
19121912
'OC\\Notification\\Notification' => __DIR__ . '/../../..' . '/lib/private/Notification/Notification.php',
19131913
'OC\\OCM\\Model\\OCMProvider' => __DIR__ . '/../../..' . '/lib/private/OCM/Model/OCMProvider.php',
19141914
'OC\\OCM\\Model\\OCMResource' => __DIR__ . '/../../..' . '/lib/private/OCM/Model/OCMResource.php',
1915+
'OC\\OCM\\OCMDiscoveryHandler' => __DIR__ . '/../../..' . '/lib/private/OCM/OCMDiscoveryHandler.php',
19151916
'OC\\OCM\\OCMDiscoveryService' => __DIR__ . '/../../..' . '/lib/private/OCM/OCMDiscoveryService.php',
19161917
'OC\\OCM\\OCMSignatoryManager' => __DIR__ . '/../../..' . '/lib/private/OCM/OCMSignatoryManager.php',
19171918
'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)