File tree Expand file tree Collapse file tree 5 files changed +35
-17
lines changed
Expand file tree Collapse file tree 5 files changed +35
-17
lines changed Original file line number Diff line number Diff line change 2929use OCP \Share \Exceptions \ShareNotFound ;
3030use OCP \Share \IAttributes ;
3131use OCP \Share \IShare ;
32+ use OCP \Share \IShareProviderSupportsAccept ;
3233use OCP \Share \IShareProviderWithNotification ;
3334use Psr \Log \LoggerInterface ;
3435use function str_starts_with ;
3839 *
3940 * @package OC\Share20
4041 */
41- class DefaultShareProvider implements IShareProviderWithNotification {
42+ class DefaultShareProvider implements IShareProviderWithNotification, IShareProviderSupportsAccept {
4243 // Special share type for user modified group shares
4344 public const SHARE_TYPE_USERGROUP = 2 ;
4445
Original file line number Diff line number Diff line change 4444use OCP \Share \IProviderFactory ;
4545use OCP \Share \IShare ;
4646use OCP \Share \IShareProvider ;
47+ use OCP \Share \IShareProviderSupportsAccept ;
4748use OCP \Share \IShareProviderWithNotification ;
4849use Psr \Log \LoggerInterface ;
4950
@@ -905,17 +906,17 @@ public function updateShare(IShare $share) {
905906 * @param IShare $share
906907 * @param string $recipientId
907908 * @return IShare The share object
908- * @throws \InvalidArgumentException
909+ * @throws \InvalidArgumentException Thrown if the provider does not implement `IShareProviderSupportsAccept`
909910 * @since 9.0.0
910911 */
911912 public function acceptShare (IShare $ share , string $ recipientId ): IShare {
912913 [$ providerId ,] = $ this ->splitFullId ($ share ->getFullId ());
913914 $ provider = $ this ->factory ->getProvider ($ providerId );
914915
915- if (!method_exists ($ provider , 'acceptShare ' )) {
916- // TODO FIX ME
916+ if (!($ provider instanceof IShareProviderSupportsAccept)) {
917917 throw new \InvalidArgumentException ('Share provider does not support accepting ' );
918918 }
919+ /** @var IShareProvider&IShareProviderSupportsAccept $provider */
919920 $ provider ->acceptShare ($ share , $ recipientId );
920921
921922 $ event = new ShareAcceptedEvent ($ share );
Original file line number Diff line number Diff line change @@ -44,16 +44,6 @@ public function create(\OCP\Share\IShare $share);
4444 */
4545 public function update (\OCP \Share \IShare $ share );
4646
47- /**
48- * Accept a share.
49- *
50- * @param IShare $share
51- * @param string $recipient
52- * @return IShare The share object
53- * @since 17.0.0
54- */
55- // public function acceptShare(IShare $share, string $recipient): IShare;
56-
5747 /**
5848 * Delete a share
5949 *
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
5+ * SPDX-License-Identifier: AGPL-3.0-or-later
6+ */
7+ namespace OCP \Share ;
8+
9+ /**
10+ * Interface IShareProviderSupportsAccept
11+ *
12+ * This interface allows to define IShareProvider that can handle the `acceptShare` method,
13+ * which is available since Nextcloud 17.
14+ *
15+ * @since 30.0.0
16+ */
17+ interface IShareProviderSupportsAccept extends IShareProvider {
18+ /**
19+ * Accept a share.
20+ *
21+ * @param IShare $share
22+ * @param string $recipient
23+ * @return IShare The share object
24+ * @since 30.0.0
25+ */
26+ public function acceptShare (IShare $ share , string $ recipient ): IShare ;
27+ }
Original file line number Diff line number Diff line change 11<?php
22
33/**
4- * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
5- * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
6- * SPDX-License-Identifier: AGPL-3.0-only
4+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
5+ * SPDX-License-Identifier: AGPL-3.0-or-later
76 */
87namespace OCP \Share ;
98
You can’t perform that action at this time.
0 commit comments