Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
375ad7d
refactor(files_sharing): Set expiration date time to 23:59:59 only in…
provokateurin Sep 30, 2026
000a82c
feat(IShare): Add getProviderId()
provokateurin Sep 2, 2026
4f66ffb
feat(Share20): Dispatch ShareUpdatedEvent and ShareRestoredEvent
provokateurin Sep 2, 2026
3335679
feat(OCP\Share\Events): Add setters for the share property
provokateurin Sep 23, 2026
d3c858d
feat(SharingManager): Dispatch SharesUpdatedEvent and SharesDeletedEvent
provokateurin Sep 2, 2026
eaca61f
feat(DefaultShareProvider): Allow fetching shares of TYPE_USERGROUP
provokateurin Sep 23, 2026
f2d2e1a
feat(ITeamManager): Allow calling getMembersOfTeam() without a user
provokateurin Sep 10, 2026
c9ae78e
feat(IShareRecipientType): Add getUsers()
provokateurin Sep 10, 2026
9085f74
feat(Sharing): Add node source target management
provokateurin Sep 10, 2026
13e7912
feat(APasswordSharePropertyType): Only hash the new value if it's not…
provokateurin Sep 23, 2026
5f866ff
refactor(ISharePropertyTypeModifyValue): Modify values on format inst…
provokateurin Sep 21, 2026
79d72af
feat(Share): Add getCreatedAt() method
provokateurin Sep 23, 2026
87df80d
feat(ISharingBackend): Add getUserStatuses() method
provokateurin Sep 23, 2026
831dc66
feat(files): Add NodeNicknameSharePropertyType
provokateurin Oct 13, 2026
4f63f30
fix(ShareByMailProvider): Set share status from DB
provokateurin Oct 13, 2026
b515f0a
fix(Share20): Fix restoring target after share was created
provokateurin Oct 27, 2026
2a1ed72
fix(FederatedShareProvider): Use existing share time and target if av…
provokateurin Oct 27, 2026
3afbee2
refactor(Share): Allow checking effective enabled permissions for exp…
provokateurin Oct 27, 2026
1bdfb63
feat(Sharing): Implement bi-directional syncing with legacy sharing
provokateurin Sep 23, 2026
f5648ac
test(integration): Enable Unified Sharing legacy sync validation
provokateurin Sep 23, 2026
6fad6c3
chore(Sharing): Remove outdated TODOs
provokateurin Oct 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions apps/federatedfilesharing/lib/FederatedShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace OCA\FederatedFileSharing;

use DateTime;
use OC\Share20\Exception\InvalidShare;
use OC\Share20\Share;
use OCP\Constants;
Expand Down Expand Up @@ -135,7 +136,7 @@ public function create(IShare $share): IShare {

if ($remoteShare) {
$ownerCloudId = $this->cloudIdManager->getCloudId($remoteShare['owner'], $remoteShare['remote']);
$shareId = $this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, 'tmp_token_' . time(), $shareType, $expirationDate);
$shareId = $this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, $share->getToken() ?? ('tmp_token_' . time()), $shareType, $expirationDate, $share->getShareTime());
[$token, $remoteId] = $this->notifications->requestReShare(
$remoteShare['refresh_token'],
$remoteShare['remote_id'],
Expand Down Expand Up @@ -170,7 +171,7 @@ public function create(IShare $share): IShare {
* @throws \Exception
*/
protected function createFederatedShare(IShare $share): string {
$token = $this->tokenHandler->generateToken();
$token = $share->getToken() ?? $this->tokenHandler->generateToken();
$shareId = $this->addShareToDB(
$share->getNodeId(),
$share->getNodeType(),
Expand All @@ -180,7 +181,8 @@ protected function createFederatedShare(IShare $share): string {
$share->getPermissions(),
$token,
$share->getShareType(),
$share->getExpirationDate()
$share->getExpirationDate(),
$share->getShareTime(),
);

$failure = false;
Expand Down Expand Up @@ -261,7 +263,7 @@ protected function getShareFromExternalShareTable(string $owner, string $target)
* @param int $shareType
* @param \DateTime $expirationDate
*/
private function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $shareType, $expirationDate): string {
private function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $shareType, $expirationDate, DateTime $shareTime): string {
$qb = $this->dbConnection->getQueryBuilder();
$qb->insert('share')
->setValue('share_type', $qb->createNamedParameter($shareType))
Expand All @@ -274,7 +276,7 @@ private function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ui
->setValue('permissions', $qb->createNamedParameter($permissions))
->setValue('expiration', $qb->createNamedParameter($expirationDate, IQueryBuilder::PARAM_DATETIME_MUTABLE))
->setValue('token', $qb->createNamedParameter($token))
->setValue('stime', $qb->createNamedParameter(time()));
->setValue('stime', $qb->createNamedParameter($shareTime->getTimestamp()));

/*
* Added to fix https://github.com/owncloud/core/issues/22215
Expand Down
2 changes: 1 addition & 1 deletion apps/files/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<name>Files</name>
<summary>File Management</summary>
<description>File Management</description>
<version>4.0.0-dev.0</version>
<version>4.0.0-dev.1</version>
<licence>agpl</licence>
<author>John Molakvoæ</author>
<author>Robin Appelman</author>
Expand Down
4 changes: 4 additions & 0 deletions apps/files/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
'OCA\\Files\\Migration\\Version11301Date20191205150729' => $baseDir . '/../lib/Migration/Version11301Date20191205150729.php',
'OCA\\Files\\Migration\\Version12101Date20221011153334' => $baseDir . '/../lib/Migration/Version12101Date20221011153334.php',
'OCA\\Files\\Migration\\Version2003Date20241021095629' => $baseDir . '/../lib/Migration/Version2003Date20241021095629.php',
'OCA\\Files\\Migration\\Version35000Date20260910082613' => $baseDir . '/../lib/Migration/Version35000Date20260910082613.php',
'OCA\\Files\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php',
'OCA\\Files\\ResponseDefinitions' => $baseDir . '/../lib/ResponseDefinitions.php',
'OCA\\Files\\Search\\FileAccountScopedSearchProvider' => $baseDir . '/../lib/Search/FileAccountScopedSearchProvider.php',
Expand All @@ -106,6 +107,9 @@
'OCA\\Files\\Sharing\\Permission\\NodeReadSharePermissionType' => $baseDir . '/../lib/Sharing/Permission/NodeReadSharePermissionType.php',
'OCA\\Files\\Sharing\\Permission\\NodeUpdateSharePermissionType' => $baseDir . '/../lib/Sharing/Permission/NodeUpdateSharePermissionType.php',
'OCA\\Files\\Sharing\\Property\\NodeGridViewSharePropertyType' => $baseDir . '/../lib/Sharing/Property/NodeGridViewSharePropertyType.php',
'OCA\\Files\\Sharing\\Property\\NodeNicknameSharePropertyType' => $baseDir . '/../lib/Sharing/Property/NodeNicknameSharePropertyType.php',
'OCA\\Files\\Sharing\\SharesUpdatedListener' => $baseDir . '/../lib/Sharing/SharesUpdatedListener.php',
'OCA\\Files\\Sharing\\SourceNodeTargetManager' => $baseDir . '/../lib/Sharing/SourceNodeTargetManager.php',
'OCA\\Files\\Sharing\\Source\\NodeShareSourceMetadata' => $baseDir . '/../lib/Sharing/Source/NodeShareSourceMetadata.php',
'OCA\\Files\\Sharing\\Source\\NodeShareSourceType' => $baseDir . '/../lib/Sharing/Source/NodeShareSourceType.php',
'OCA\\Files\\TokenScopes' => $baseDir . '/../lib/TokenScopes.php',
Expand Down
4 changes: 4 additions & 0 deletions apps/files/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class ComposerStaticInitFiles
'OCA\\Files\\Migration\\Version11301Date20191205150729' => __DIR__ . '/..' . '/../lib/Migration/Version11301Date20191205150729.php',
'OCA\\Files\\Migration\\Version12101Date20221011153334' => __DIR__ . '/..' . '/../lib/Migration/Version12101Date20221011153334.php',
'OCA\\Files\\Migration\\Version2003Date20241021095629' => __DIR__ . '/..' . '/../lib/Migration/Version2003Date20241021095629.php',
'OCA\\Files\\Migration\\Version35000Date20260910082613' => __DIR__ . '/..' . '/../lib/Migration/Version35000Date20260910082613.php',
'OCA\\Files\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php',
'OCA\\Files\\ResponseDefinitions' => __DIR__ . '/..' . '/../lib/ResponseDefinitions.php',
'OCA\\Files\\Search\\FileAccountScopedSearchProvider' => __DIR__ . '/..' . '/../lib/Search/FileAccountScopedSearchProvider.php',
Expand All @@ -121,6 +122,9 @@ class ComposerStaticInitFiles
'OCA\\Files\\Sharing\\Permission\\NodeReadSharePermissionType' => __DIR__ . '/..' . '/../lib/Sharing/Permission/NodeReadSharePermissionType.php',
'OCA\\Files\\Sharing\\Permission\\NodeUpdateSharePermissionType' => __DIR__ . '/..' . '/../lib/Sharing/Permission/NodeUpdateSharePermissionType.php',
'OCA\\Files\\Sharing\\Property\\NodeGridViewSharePropertyType' => __DIR__ . '/..' . '/../lib/Sharing/Property/NodeGridViewSharePropertyType.php',
'OCA\\Files\\Sharing\\Property\\NodeNicknameSharePropertyType' => __DIR__ . '/..' . '/../lib/Sharing/Property/NodeNicknameSharePropertyType.php',
'OCA\\Files\\Sharing\\SharesUpdatedListener' => __DIR__ . '/..' . '/../lib/Sharing/SharesUpdatedListener.php',
'OCA\\Files\\Sharing\\SourceNodeTargetManager' => __DIR__ . '/..' . '/../lib/Sharing/SourceNodeTargetManager.php',
'OCA\\Files\\Sharing\\Source\\NodeShareSourceMetadata' => __DIR__ . '/..' . '/../lib/Sharing/Source/NodeShareSourceMetadata.php',
'OCA\\Files\\Sharing\\Source\\NodeShareSourceType' => __DIR__ . '/..' . '/../lib/Sharing/Source/NodeShareSourceType.php',
'OCA\\Files\\TokenScopes' => __DIR__ . '/..' . '/../lib/TokenScopes.php',
Expand Down
13 changes: 13 additions & 0 deletions apps/files/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace OCA\Files\AppInfo;

use NCU\Sharing\Event\SharesUpdatedEvent;
use NCU\Sharing\ISharingRegistry;
use OC\Core\Sharing\Permission\EditSharePermissionPreset;
use OC\Core\Sharing\Permission\ViewSharePermissionPreset;
Expand Down Expand Up @@ -43,6 +44,8 @@
use OCA\Files\Sharing\Permission\NodeReadSharePermissionType;
use OCA\Files\Sharing\Permission\NodeUpdateSharePermissionType;
use OCA\Files\Sharing\Property\NodeGridViewSharePropertyType;
use OCA\Files\Sharing\Property\NodeNicknameSharePropertyType;
use OCA\Files\Sharing\SharesUpdatedListener;
use OCA\Files\Sharing\Source\NodeShareSourceType;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
Expand Down Expand Up @@ -106,6 +109,12 @@ public function register(IRegistrationContext $context): void {

$context->registerEventListener(RestrictInteractionEvent::class, RestrictInteractionListener::class);

$context->registerEventListener(SharesUpdatedEvent::class, SharesUpdatedListener::class);

$this->registerSharing();
}

private function registerSharing(): void {
$registry = Server::get(ISharingRegistry::class);

$registry->registerSourceType(Server::get(NodeShareSourceType::class));
Expand All @@ -118,6 +127,10 @@ public function register(IRegistrationContext $context): void {
$registry->markPropertyTypeCompatibleWithSourceType(NodeGridViewSharePropertyType::class, NodeShareSourceType::class);
$registry->markPropertyTypeCompatibleWithRecipientType(NodeGridViewSharePropertyType::class, TokenShareRecipientType::class);

$registry->registerPropertyType(new NodeNicknameSharePropertyType());
$registry->markPropertyTypeCompatibleWithSourceType(NodeNicknameSharePropertyType::class, NodeShareSourceType::class);
$registry->markPropertyTypeCompatibleWithRecipientType(NodeNicknameSharePropertyType::class, TokenShareRecipientType::class);

$registry->registerPermissionType(NodeShareSourceType::class, Server::get(NodeCreateSharePermissionType::class));
$registry->markPermissionTypeCompatibleWithPermissionPreset(NodeCreateSharePermissionType::class, EditSharePermissionPreset::class);

Expand Down
37 changes: 37 additions & 0 deletions apps/files/lib/Migration/Version35000Date20260910082613.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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::TEXT, ['length' => 64]);
$sourceNodeTargetTable->addColumn('source_instance', Types::STRING, ['length' => 128, 'notnull' => false]);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this and any code using it will need to be adjusted once #65512 is in

$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', 'source_node_id']);

return $schema;
}
}
47 changes: 47 additions & 0 deletions apps/files/lib/Sharing/Property/NodeNicknameSharePropertyType.php
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';
}
}
77 changes: 77 additions & 0 deletions apps/files/lib/Sharing/SharesUpdatedListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?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\ISharingManager;
use NCU\Sharing\ISharingRegistry;
use NCU\Sharing\ShareAccessContext;
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 ISharingManager $manager,
private ISharingRegistry $registry,
private SourceNodeTargetManager $sourceNodeTargetManager,
private IRootFolder $rootFolder,
) {
}

#[Override]
public function handle(Event $event): void {
foreach ($event->shareIds as $shareId) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we send the share objects with the event to prevent having to re-fetch them here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The problem is that in the place where the event is emitted the share is from the perspective of the user. At least in the sync part we need to fetch the full share. I only sent the IDs, to avoid this kind of confusion, because listeners would likely assume that they see the full share.

So I would like to keep it like this to make sure the event is not used in the wrong way. Alternatively the shares could be re-fetched before the event is emitted, so the case of multiple listeners would be optimized, because they don't need to fetch the shares each.

$share = $this->manager->getShare(new ShareAccessContext(overrideChecks: true), $shareId);
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();
}

$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 $userId) {
$userIds[$userId] = true;
}
}

$this->sourceNodeTargetManager->getTargets(array_keys($userIds), $share->owner, $sourceNode);
}
}
}
}
Loading
Loading