Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions apps/files/tests/Sharing/Source/NodeShareSourceTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use OC\Files\Filesystem;
use OC\User\Database;
use OCA\Files\Sharing\Source\NodeShareSourceType;
use OCA\Sharing\SharingBackend;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
Expand Down Expand Up @@ -95,7 +94,6 @@ public function testGetSourceIcon(): void {
public function testDelete(): void {
$registry = Server::get(ISharingRegistry::class);
$registry->clear();
$registry->registerSharingBackend(Server::get(SharingBackend::class));
$registry->registerSourceType($this->sourceType);

$accessContext = new ShareAccessContext(currentUser: $this->user1);
Expand Down
4 changes: 3 additions & 1 deletion apps/sharebymail/lib/ShareByMailProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ protected function publishActivity(string $subject, array $parameters, string $a
* @throws \Exception
*/
protected function createMailShare(IShare $share): string {
$share->setToken($this->generateToken());
if ($share->getToken() === '') {
$share->setToken($this->generateToken());
}
return $this->addShareToDB(
$share->getNodeId(),
$share->getNodeType(),
Expand Down
2 changes: 1 addition & 1 deletion apps/sharebymail/tests/ShareByMailProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ public function testCreateFailed(): void {
}

public function testCreateMailShare(): void {
$this->share->expects($this->any())->method('getToken')->willReturn('token');
$this->share->expects($this->any())->method('getToken')->willReturn('');
$this->share->expects($this->once())->method('setToken')->with('token');
$this->share->expects($this->any())->method('getSharedBy')->willReturn('validby@valid.com');
$this->share->expects($this->any())->method('getSharedWith')->willReturn('validwith@valid.com');
Expand Down
1 change: 0 additions & 1 deletion apps/sharing/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@
'OCA\\Sharing\\Middleware\\ShareApiEnabledMiddleware' => $baseDir . '/../lib/Middleware/ShareApiEnabledMiddleware.php',
'OCA\\Sharing\\Migration\\Version1000Date20250929161325' => $baseDir . '/../lib/Migration/Version1000Date20250929161325.php',
'OCA\\Sharing\\ResponseDefinitions' => $baseDir . '/../lib/ResponseDefinitions.php',
'OCA\\Sharing\\SharingBackend' => $baseDir . '/../lib/SharingBackend.php',
);
1 change: 0 additions & 1 deletion apps/sharing/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class ComposerStaticInitSharing
'OCA\\Sharing\\Middleware\\ShareApiEnabledMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/ShareApiEnabledMiddleware.php',
'OCA\\Sharing\\Migration\\Version1000Date20250929161325' => __DIR__ . '/..' . '/../lib/Migration/Version1000Date20250929161325.php',
'OCA\\Sharing\\ResponseDefinitions' => __DIR__ . '/..' . '/../lib/ResponseDefinitions.php',
'OCA\\Sharing\\SharingBackend' => __DIR__ . '/..' . '/../lib/SharingBackend.php',
);

public static function getInitializer(ClassLoader $loader)
Expand Down
6 changes: 0 additions & 6 deletions apps/sharing/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@

namespace OCA\Sharing\AppInfo;

use NCU\Sharing\ISharingRegistry;
use OCA\Sharing\Capabilities;
use OCA\Sharing\Middleware\ShareApiEnabledMiddleware;
use OCA\Sharing\SharingBackend;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\Server;

final class Application extends App implements IBootstrap {
public const string APP_ID = 'sharing';
Expand All @@ -30,9 +27,6 @@ public function __construct(array $urlParams = []) {
public function register(IRegistrationContext $context): void {
$context->registerCapability(Capabilities::class);
$context->registerMiddleware(ShareApiEnabledMiddleware::class);

$registry = Server::get(ISharingRegistry::class);
$registry->registerSharingBackend(Server::get(SharingBackend::class));
}

#[\Override]
Expand Down
2 changes: 2 additions & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2296,6 +2296,8 @@
'OC\\Share20\\UserDeletedListener' => $baseDir . '/lib/private/Share20/UserDeletedListener.php',
'OC\\Share20\\UserRemovedListener' => $baseDir . '/lib/private/Share20/UserRemovedListener.php',
'OC\\Share\\Constants' => $baseDir . '/lib/private/Share/Constants.php',
'OC\\Sharing\\ISharingLegacyBackend' => $baseDir . '/lib/private/Sharing/ISharingLegacyBackend.php',
'OC\\Sharing\\SharingBackend' => $baseDir . '/lib/private/Sharing/SharingBackend.php',
'OC\\Sharing\\SharingManager' => $baseDir . '/lib/private/Sharing/SharingManager.php',
'OC\\Sharing\\SharingRegistry' => $baseDir . '/lib/private/Sharing/SharingRegistry.php',
'OC\\Snowflake\\APCuSequence' => $baseDir . '/lib/private/Snowflake/APCuSequence.php',
Expand Down
2 changes: 2 additions & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -2337,6 +2337,8 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Share20\\UserDeletedListener' => __DIR__ . '/../../..' . '/lib/private/Share20/UserDeletedListener.php',
'OC\\Share20\\UserRemovedListener' => __DIR__ . '/../../..' . '/lib/private/Share20/UserRemovedListener.php',
'OC\\Share\\Constants' => __DIR__ . '/../../..' . '/lib/private/Share/Constants.php',
'OC\\Sharing\\ISharingLegacyBackend' => __DIR__ . '/../../..' . '/lib/private/Sharing/ISharingLegacyBackend.php',
'OC\\Sharing\\SharingBackend' => __DIR__ . '/../../..' . '/lib/private/Sharing/SharingBackend.php',
'OC\\Sharing\\SharingManager' => __DIR__ . '/../../..' . '/lib/private/Sharing/SharingManager.php',
'OC\\Sharing\\SharingRegistry' => __DIR__ . '/../../..' . '/lib/private/Sharing/SharingRegistry.php',
'OC\\Snowflake\\APCuSequence' => __DIR__ . '/../../..' . '/lib/private/Snowflake/APCuSequence.php',
Expand Down
10 changes: 6 additions & 4 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ protected function generalChecks(IShare $share): void {
throw new GenericShareException($isRestricted, code: 403);
}
} catch (\Exception $exception) {
throw new GenericShareException($exception->getMessage(), $exception instanceof HintException ? $exception->getHint() : '', code: 403);
throw new GenericShareException($exception->getMessage(), $exception instanceof HintException ? $exception->getHint() : '', code: 403, previous: $exception);
}
}
}
Expand Down Expand Up @@ -567,9 +567,11 @@ public function createShare(IShare $share): IShare {
|| $share->getShareType() === IShare::TYPE_EMAIL) {
$this->setLinkParent($share);

$token = $this->generateToken();
// Set the unique token
$share->setToken($token);
if ($share->getToken() === '') {
$token = $this->generateToken();
// Set the unique token
$share->setToken($token);
}

// Verify the expiration date
$share = $this->validateExpirationDateLink($share);
Expand Down
10 changes: 5 additions & 5 deletions lib/private/Share20/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Share implements IShare {
private $fileId;
/** @var string */
private $nodeType;
/** @var int */
/** @var IShare::TYPE_* */
private $shareType;
/** @var string */
private $sharedWith;
Expand All @@ -44,11 +44,11 @@ class Share implements IShare {
private $sharedBy;
/** @var string */
private $shareOwner;
/** @var int */
/** @var int-mask-of<Constants::PERMISSION_*> */
private $permissions;
/** @var IAttributes */
private $attributes;
/** @var int */
/** @var self::STATUS_* */
private $status;
/** @var string */
private $note = '';
Expand All @@ -60,7 +60,7 @@ class Share implements IShare {
/** @var bool */
private $sendPasswordByTalk = false;
/** @var string */
private $token;
private $token = '';
private ?int $parent = null;
/** @var string */
private $target;
Expand Down Expand Up @@ -358,7 +358,7 @@ public function setStatus(int $status): IShare {
* @inheritdoc
*/
#[\Override]
public function getStatus(): int {
public function getStatus(): ?int {
return $this->status;
}

Expand Down
59 changes: 59 additions & 0 deletions lib/private/Sharing/ISharingLegacyBackend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

declare(strict_types=1);

namespace OC\Sharing;

use NCU\Sharing\Exception\ShareNotFoundException;
use NCU\Sharing\Recipient\IShareRecipientType;
use NCU\Sharing\Share;
use NCU\Sharing\ShareAccessContext;
use NCU\Sharing\Source\IShareSourceType;

/**
* This interface is only temporary and implemented in the files_sharing app.
*/
interface ISharingLegacyBackend {
Comment thread
provokateurin marked this conversation as resolved.
/**
* @return list<class-string<IShareSourceType>>
*/
public function getCompatibleSourceTypes(): array;

/**
* @return list<class-string<IShareRecipientType>>
*/
public function getCompatibleRecipientTypes(): array;

/**
* Update a share.
*/
public function updateShare(Share $share): void;

/**
* Delete a share.
*
* @throws ShareNotFoundException
*/
public function deleteShare(string $id): void;

/**
* Get a share.
*
* @throws ShareNotFoundException
*/
public function getShare(ShareAccessContext $accessContext, string $id): Share;

/**
* Get multiple shares.
*
* @param ?class-string<IShareSourceType> $filterSourceTypeClass
* @param ?positive-int $limit
* @return list<Share>
*/
public function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array;
}
Loading
Loading