Skip to content

Conversation

@ArtificialOwl
Copy link
Member

@ArtificialOwl ArtificialOwl commented Dec 7, 2025

Allow any app to register new OCM capabilities and manage requests to remote OCM endpoints.
This is done by:

  • broadcasting a OCMEndpointRequestEvent event on incoming request on /ocm/,
  • and completing current OCM API, aside with some global polishing, with tools to request a remote OCM endpoint.

Complete list of changes:

  • rename local ocm discovery event to a more fitted description (ResourceTypeRegisterEvent => LocalOCMDiscoveryEvent)
  • ability to add capability to local OCM discovery
  • ability to generate custom OCM requests to remote instance
  • event on /ocm/ requests to externally manage behavior
  • event on /ocm/ requests can extract typed arguments
  • event on /ocm/ support signed request
  • event on /ocm/ contains attached payload
  • remove slashes from capabilities (as expected in ocm 1.2)
  • making legacy route parser to manage a list of methods
  • get rid of ICapabilityAwareOCMProvider and rehabilitate IOCMProvider

  • tests

Events Listeners

Examples of listeners to inject your app into OCM

Adding a new capability to the local instance

class OCMDiscovery implements IEventListener {
	public function __construct(
	) {
	}

	public function handle(Event $event): void {
		if (!($event instanceof \OCP\OCM\Events\LocalOCMDiscoveryEvent)) {
			return;
		}

		$event->addCapability('my-own-capability');
	}
}

Catching requests made on the ocm endpoint

base url is _https://cloud.example.net/ocm/..._

class OCMRequest implements IEventListener {
	public function __construct(
	) {
	}

	public function handle(Event $event): void {
		if (!($event instanceof \OCP\OCM\Events\OCMEndpointRequestEvent)) {
			return;
		}

		$event->setResponse(new DataResponse(
			[
				'_capability' => $event->getRequestedCapability(),
				'_method' => $event->getUsedMethod(),
				'_path' => $event->getPath(),
				'_args' => $event->getArgs(),
				'_typedArgs' => $event->getArgs(
					\OCP\OCM\Enum\ParamType::STRING,
					\OCP\OCM\Enum\ParamType::STRING,
					\OCP\OCM\Enum\ParamType::INT,
					\OCP\OCM\Enum\ParamType::BOOL,
					\OCP\OCM\Enum\ParamType::INT
				)
			]
		));
	}
}

Expected data

Some example of curl requests ...

Discovery endpoint

$ curl https://cloud.example.net/ocm-provider/ | jq .
{
  "enabled": true,
  "apiVersion": "1.0-proposal1",
  "version": "1.1.0",
  "endPoint": "https://cloud.example.net/index.php/ocm",
[...]  
  "capabilities": [
    "invite-accepted",
    "notifications",
    "shares",
    "my-own-capability"
  ]
}

OCM request

$ curl -X POST -k https://cloud.example.net/ocm/my-own-capability/arg1/arg2/50/yes/not-integer/moar/ignored | jq .
{
  "_capability": "my-own-capability",
  "_method": "POST",
  "_path": "/arg1/arg2/50/yes/not-integer/moar/ignored",
  "_args": [
    "arg1",
    "arg2",
    "50",
    "yes",
    "not-integer",
    "moar",
    "ignored"
  ],
  "_typedArgs": [
    "arg1",
    "arg2",
    50,
    true,
    null
  ]
}

@ArtificialOwl ArtificialOwl force-pushed the feat/noid/ocm-capabilities branch 8 times, most recently from ae8f5a7 to 94491e8 Compare December 13, 2025 10:40
@ArtificialOwl ArtificialOwl force-pushed the feat/noid/ocm-capabilities branch 2 times, most recently from fa9222a to e6ad3a5 Compare December 16, 2025 16:34
@ArtificialOwl ArtificialOwl added the 3. to review Waiting for reviews label Dec 16, 2025
@ArtificialOwl ArtificialOwl added this to the Nextcloud 33 milestone Dec 16, 2025
@ArtificialOwl ArtificialOwl marked this pull request as ready for review December 17, 2025 22:03
@ArtificialOwl ArtificialOwl requested review from a team and nickvergessen as code owners December 17, 2025 22:03
@ArtificialOwl ArtificialOwl requested review from Altahrim, come-nc, icewind1991 and salmart-dev and removed request for a team December 17, 2025 22:03
@ArtificialOwl ArtificialOwl force-pushed the feat/noid/ocm-capabilities branch from e6ad3a5 to d3c3894 Compare January 5, 2026 13:50
@ArtificialOwl ArtificialOwl mentioned this pull request Jan 6, 2026
Copy link
Collaborator

@Altahrim Altahrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete review

@ArtificialOwl ArtificialOwl force-pushed the feat/noid/ocm-capabilities branch from d3c3894 to cd231dd Compare January 7, 2026 10:27
@ArtificialOwl
Copy link
Member Author

Incomplete review

thanks for this, fixed most of the reported minor issues

@nextcloud-bot nextcloud-bot mentioned this pull request Jan 7, 2026
@ArtificialOwl ArtificialOwl force-pushed the feat/noid/ocm-capabilities branch from cd231dd to 0b6e3a8 Compare January 7, 2026 10:55
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
@ArtificialOwl ArtificialOwl force-pushed the feat/noid/ocm-capabilities branch from 0b6e3a8 to 6af64a5 Compare January 7, 2026 18:55
@ArtificialOwl
Copy link
Member Author

ArtificialOwl commented Jan 7, 2026

@Altahrim I did the requested changes

@Altahrim Altahrim merged commit ae25077 into master Jan 8, 2026
245 of 259 checks passed
@Altahrim Altahrim deleted the feat/noid/ocm-capabilities branch January 8, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants