Skip to content

Commit

Permalink
fix: Add acceptShare as an interface
Browse files Browse the repository at this point in the history
It was commented out because at that time no other share provider
supported the `acceptShare` method. Today it is the same no other provider
supports it, but we should make it discoverable by adding it to the public API
as an additional interface.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Jun 25, 2024
1 parent eed6216 commit e3d9d6d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lib/private/Share20/DefaultShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCP\Share\IAttributes;
use OCP\Share\IShare;
use OCP\Share\IShareProvider;
use OCP\Share\IShareProviderSupportsAccept;
use Psr\Log\LoggerInterface;
use function str_starts_with;

Expand All @@ -37,7 +38,7 @@
*
* @package OC\Share20
*/
class DefaultShareProvider implements IShareProvider {
class DefaultShareProvider implements IShareProvider, IShareProviderSupportsAccept {
// Special share type for user modified group shares
public const SHARE_TYPE_USERGROUP = 2;

Expand Down
2 changes: 2 additions & 0 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use OCP\Share\IProviderFactory;
use OCP\Share\IShare;
use OCP\Share\IShareProvider;
use OCP\Share\IShareProviderSupportsAccept;
use Psr\Log\LoggerInterface;

/**
Expand Down Expand Up @@ -1018,6 +1019,7 @@ public function acceptShare(IShare $share, string $recipientId): IShare {
// TODO FIX ME
throw new \InvalidArgumentException('Share provider does not support accepting');
}
/** @var IShareProvider&IShareProviderSupportsAccept $provider */
$provider->acceptShare($share, $recipientId);

$event = new ShareAcceptedEvent($share);
Expand Down
10 changes: 0 additions & 10 deletions lib/public/Share/IShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ public function create(\OCP\Share\IShare $share);
*/
public function update(\OCP\Share\IShare $share);

/**
* Accept a share.
*
* @param IShare $share
* @param string $recipient
* @return IShare The share object
* @since 17.0.0
*/
// public function acceptShare(IShare $share, string $recipient): IShare;

/**
* Delete a share
*
Expand Down
27 changes: 27 additions & 0 deletions lib/public/Share/IShareProviderSupportsAccept.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Share;

/**
* Interface IShareProviderSupportsAccept
*
* This interface allows to define IShareProvider that can handle the `acceptShare` method,
* which is available since Nextcloud 17.
*
* @since 30.0.0
*/
interface IShareProviderSupportsAccept {
/**
* Accept a share.
*
* @param IShare $share
* @param string $recipient
* @return IShare The share object
* @since 17.0.0
*/
public function acceptShare(IShare $share, string $recipient): IShare;
}

0 comments on commit e3d9d6d

Please sign in to comment.