Skip to content

Commit 0cdd192

Browse files
Merge pull request #56047 from nextcloud/feat/ocm/handle-new-ocm-endpoint
feat(ocm): handle /.well-known/ocm
2 parents 9e516be + e456f11 commit 0cdd192

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
@@ -1897,6 +1897,7 @@
18971897
'OC\\Notification\\Notification' => $baseDir . '/lib/private/Notification/Notification.php',
18981898
'OC\\OCM\\Model\\OCMProvider' => $baseDir . '/lib/private/OCM/Model/OCMProvider.php',
18991899
'OC\\OCM\\Model\\OCMResource' => $baseDir . '/lib/private/OCM/Model/OCMResource.php',
1900+
'OC\\OCM\\OCMDiscoveryHandler' => $baseDir . '/lib/private/OCM/OCMDiscoveryHandler.php',
19001901
'OC\\OCM\\OCMDiscoveryService' => $baseDir . '/lib/private/OCM/OCMDiscoveryService.php',
19011902
'OC\\OCM\\OCMSignatoryManager' => $baseDir . '/lib/private/OCM/OCMSignatoryManager.php',
19021903
'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
@@ -1938,6 +1938,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
19381938
'OC\\Notification\\Notification' => __DIR__ . '/../../..' . '/lib/private/Notification/Notification.php',
19391939
'OC\\OCM\\Model\\OCMProvider' => __DIR__ . '/../../..' . '/lib/private/OCM/Model/OCMProvider.php',
19401940
'OC\\OCM\\Model\\OCMResource' => __DIR__ . '/../../..' . '/lib/private/OCM/Model/OCMResource.php',
1941+
'OC\\OCM\\OCMDiscoveryHandler' => __DIR__ . '/../../..' . '/lib/private/OCM/OCMDiscoveryHandler.php',
19411942
'OC\\OCM\\OCMDiscoveryService' => __DIR__ . '/../../..' . '/lib/private/OCM/OCMDiscoveryService.php',
19421943
'OC\\OCM\\OCMSignatoryManager' => __DIR__ . '/../../..' . '/lib/private/OCM/OCMSignatoryManager.php',
19431944
'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)