Repository navigation
Unified Sharing Legacy Sync #65972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
provokateurin
wants to merge
23
commits into
master
Choose a base branch
from
unified-sharing-legacy-sync
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Unified Sharing Legacy Sync #65972
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
b8ab84f
fix(Sharing): Fix event listeners with ghosts
provokateurin 40869c5
refactor(Sharing): Tighten more types
provokateurin ac7453f
refactor(files_sharing): Set expiration date time to 23:59:59 only in…
provokateurin 8582ba8
feat(IShare): Add getProviderId()
provokateurin c3ca67b
feat(Share20): Dispatch ShareUpdatedEvent and ShareRestoredEvent
provokateurin 0780251
feat(OCP\Share\Events): Add setters for the share property
provokateurin 2f4f3b8
feat(SharingManager): Dispatch SharesUpdatedEvent and SharesDeletedEvent
provokateurin 891a8be
feat(DefaultShareProvider): Allow fetching shares of TYPE_USERGROUP
provokateurin b88c5b0
feat(ITeamManager): Allow calling getMembersOfTeam() without a user
provokateurin ad52e64
feat(IShareRecipientType): Add getUsers()
provokateurin 4366fdb
feat(Sharing): Add node source target management
provokateurin 07892c3
refactor(ISharePropertyTypeModifyValue): Modify values on format inst…
provokateurin d86be3b
refactor(ISharePropertyTypeModifyValue): Modify values on save in the…
provokateurin f070496
feat(Share): Add getCreatedAt() method
provokateurin e52ee50
feat(ISharingBackend): Add getUserStatuses() method
provokateurin 90cb1d0
feat(files): Add NodeNicknameSharePropertyType
provokateurin 930d76e
fix(ShareByMailProvider): Set share status from DB
provokateurin d2f4217
fix(Share20): Fix setting target before and after the share is create…
provokateurin ffdcc59
fix(FederatedShareProvider): Use existing share time and token if ava…
provokateurin 2a5e238
refactor(Share): Allow checking effective enabled permissions for exp…
provokateurin f2bf3ec
feat(Sharing): Implement bi-directional syncing with legacy sharing
provokateurin 54ed407
test(integration): Enable Unified Sharing legacy sync validation
provokateurin de07613
chore(Sharing): Remove outdated TODOs
provokateurin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
apps/files/lib/Migration/Version35000Date20260910082613.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Files\Migration; | ||
|
|
||
| use Closure; | ||
| use OCP\DB\ISchemaWrapper; | ||
| use OCP\DB\Types; | ||
| use OCP\Migration\IOutput; | ||
| use OCP\Migration\SimpleMigrationStep; | ||
| use Override; | ||
|
|
||
| final class Version35000Date20260910082613 extends SimpleMigrationStep { | ||
| /** | ||
| * @param Closure(): ISchemaWrapper $schemaClosure | ||
| */ | ||
| #[Override] | ||
| public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { | ||
| $schema = $schemaClosure(); | ||
|
|
||
| $sourceNodeTargetTable = $schema->createTable('sharing_source_node_target'); | ||
| $sourceNodeTargetTable->addColumn('user_id', Types::STRING, ['length' => 64]); | ||
| // Can't add a FK on sharing_instance_map here, because that table is created by the sharing app. | ||
| $sourceNodeTargetTable->addColumn('source_instance_id', Types::INTEGER, ['notnull' => false]); | ||
| $sourceNodeTargetTable->addColumn('source_node_id', Types::INTEGER); | ||
| $sourceNodeTargetTable->addColumn('target', Types::TEXT, ['length' => 255]); | ||
| // Primary key doesn't work, because that makes source_instance NOT NULL | ||
| $sourceNodeTargetTable->addUniqueIndex(['user_id', 'source_instance_id', 'source_node_id']); | ||
|
|
||
| return $schema; | ||
| } | ||
| } | ||
47 changes: 47 additions & 0 deletions
47
apps/files/lib/Sharing/Property/NodeNicknameSharePropertyType.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Files\Sharing\Property; | ||
|
|
||
| use NCU\Sharing\Property\ABooleanSharePropertyType; | ||
| use NCU\Sharing\Share; | ||
| use OC\Core\AppInfo\Application; | ||
| use OCP\L10N\IFactory; | ||
|
|
||
| final class NodeNicknameSharePropertyType extends ABooleanSharePropertyType { | ||
| #[\Override] | ||
| public function getDisplayName(IFactory $l10nFactory): string { | ||
| return $l10nFactory->get(Application::APP_ID)->t('Always ask recipients for a nickname before uploading files.'); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getHint(IFactory $l10nFactory, Share $share): ?string { | ||
| return null; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getPriority(): int { | ||
| return 75; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function isAdvanced(): bool { | ||
| return true; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function isRequired(Share $share): bool { | ||
| return false; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getDefaultValue(Share $share): string { | ||
| return 'false'; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace OCA\Files\Sharing; | ||
|
|
||
| use NCU\Sharing\Event\SharesUpdatedEvent; | ||
| use NCU\Sharing\ISharingRegistry; | ||
| use NCU\Sharing\ShareState; | ||
| use OCA\Files\Sharing\Source\NodeShareSourceType; | ||
| use OCP\EventDispatcher\Event; | ||
| use OCP\EventDispatcher\IEventListener; | ||
| use OCP\Files\IRootFolder; | ||
| use OCP\Files\Node; | ||
| use OCP\Files\NotFoundException; | ||
| use Override; | ||
| use RuntimeException; | ||
|
|
||
| /** | ||
| * @implements IEventListener<SharesUpdatedEvent> | ||
| */ | ||
| final readonly class SharesUpdatedListener implements IEventListener { | ||
| public function __construct( | ||
| private ISharingRegistry $registry, | ||
| private SourceNodeTargetManager $sourceNodeTargetManager, | ||
| private IRootFolder $rootFolder, | ||
| ) { | ||
| } | ||
|
|
||
| #[Override] | ||
| public function handle(Event $event): void { | ||
| foreach ($event->getShares() as $share) { | ||
| if ($share->state !== ShareState::Active) { | ||
| continue; | ||
| } | ||
|
|
||
| $ownerUserFolder = $this->rootFolder->getUserFolder($share->owner->userId); | ||
|
|
||
| foreach ($share->sources as $source) { | ||
| if ($source->class !== NodeShareSourceType::class) { | ||
| continue; | ||
| } | ||
|
|
||
| $sourceNode = $ownerUserFolder->getFirstNodeById((int)$source->value); | ||
| if (!$sourceNode instanceof Node) { | ||
| throw new NotFoundException(); | ||
| } | ||
|
|
||
| /** @var array<int|string, true> */ | ||
| $userIds = []; | ||
| foreach ($share->recipients as $recipient) { | ||
| if ($recipient->instance !== null) { | ||
| continue; | ||
| } | ||
|
|
||
| if (($recipientType = $this->registry->getRecipientTypes()[$recipient->class] ?? null) === null) { | ||
| throw new RuntimeException('The recipient type is not registered: ' . $recipient->class); | ||
| } | ||
|
|
||
| foreach ($recipientType->getUsers($recipient->value) as $user) { | ||
| $userIds[$user->getUID()] = true; | ||
| } | ||
| } | ||
|
|
||
| // Casting is needed, because using the user ID as the array key could convert it to an integer if it is numeric. | ||
| $this->sourceNodeTargetManager->getTargets(array_map(static fn (int|string $userId): string => (string)$userId, array_keys($userIds)), $share->owner, $sourceNode); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.