From 520042bbd0512e19717d18705c3b045b2d8400a7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 4 Sep 2019 16:50:52 +0200 Subject: Allow to accept group shares Signed-off-by: Joas Schilling --- lib/private/Share20/Manager.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lib/private/Share20/Manager.php') diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 728dd60e759..ba370e7724a 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -928,6 +928,30 @@ class Manager implements IManager { return $share; } + /** + * Accept a share. + * + * @param IShare $share + * @param string $recipientId + * @return IShare The share object + * @throws \InvalidArgumentException + * @since 9.0.0 + */ + public function acceptShare(IShare $share, string $recipientId): IShare { + [$providerId, ] = $this->splitFullId($share->getFullId()); + $provider = $this->factory->getProvider($providerId); + + if (!method_exists($provider, 'acceptShare')) { + // TODO FIX ME + throw new \InvalidArgumentException('not supported'); + } + $provider->acceptShare($share, $recipientId); + $event = new GenericEvent($share); + $this->eventDispatcher->dispatch('OCP\Share::postAcceptShare', $event); + + return $share; + } + /** * Updates the password of the given share if it is not the same as the * password of the original share. -- cgit v1.2.3