Skip to content

feat: send unified shares to remote instances via ocm - #66569

Draft
cristianscheid wants to merge 1 commit into
masterfrom
feat/64711/unified-sharing-ocm
Draft

cristianscheid wants to merge 1 commit into
masterfrom
feat/64711/unified-sharing-ocm

Conversation

@cristianscheid

@cristianscheid cristianscheid commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Summary

Currently, when creating a unified share with a user living in remote instance, share is only created locally and not propagated. The goal of this PR is to send the unified share to remote instance OCM /shares endpoint, so it can be created there as well.

The unified share is sent to remote instances only if it contains remote recipients, in the following events:

  • share changed state to active
  • a remote recipient was added to a share already in active state

In the case where a unified share is composed by multiple sources, one OCM share is sent to each source. To be able to assemble the share again on receiving end, the OCM providerId field is formatted like this:

unified:{shareId}:{recipientId}:{sourceValue}

As per OCM docs, this value must be unique per resource and per share.

This is only a first iteration of development that focuses on sending the necessary data to the remote instance. The receiving part was not yet modified, and for now, stores the share in legacy format (oc_share_external).

Also, after receiving the OCM share, the receiving end is supposed to send callbacks back to the sender (token exchange and share accepted). This is not working for now and exceptions are thrown, because sender still looks up the for share secret in the legacy table oc_share, but it's not there since it is a unified share.

To test this:

  • setup federated environment with two instances (e.g. nextcloud.local + nextcloud2.local)
  • create unified sharing with bob@nextcloud2.local from nextcloud.local:
# from nextcloud.local:
occ config:system:set sharing.unified_api_enable --value=true --type=boolean
occ sharing:create-share admin
occ sharing:add-share-source SHARE_ID 'OCA\Files\Sharing\Source\NodeShareSourceType' FILE_ID
occ sharing:add-share-recipient --actor admin SHARE_ID 'OC\Core\Sharing\Recipient\UserShareRecipientType' bob nextcloud2.local
occ sharing:update-share-state SHARE_ID active
  • after this, oc_share_external on nextcloud2.local gets populated:
{"id":151679734664732673,"parent":-1,"share_type":0,"remote":"https://nextcloud.local/","remote_id":"unified:151679016426491904:151679480995991552:94","password":null,"name":"/test_folder","owner":"admin","user":"bob","mountpoint":"/test_folder","mountpoint_hash":"<hash>","accepted":1,"access_token":null,"access_token_expires":null,"refresh_token":"<token>"}

TODO

  • ...

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@cristianscheid cristianscheid self-assigned this Nov 13, 2026
@cristianscheid
cristianscheid force-pushed the feat/64711/unified-sharing-ocm branch from e2e1771 to 7967497 Compare November 13, 2026 18:37
@cristianscheid
cristianscheid force-pushed the feat/64711/unified-sharing-ocm branch from 7967497 to 12e82b9 Compare November 13, 2026 18:44
Signed-off-by: Cristian Scheid <cristianscheid@gmail.com>
@cristianscheid
cristianscheid force-pushed the feat/64711/unified-sharing-ocm branch from 12e82b9 to 7ef478b Compare November 13, 2026 18:48
@mickenordin

Copy link
Copy Markdown
Contributor

For this, I would really recommend setting up at least OpenCloud and trying to share to that, and make sure it still works.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants