aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/Share20/Manager.php9
-rw-r--r--tests/lib/Share20/ManagerTest.php50
2 files changed, 59 insertions, 0 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 7cfa83dbb4a..037ea53048a 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -1248,6 +1248,15 @@ class Manager implements IManager {
}
}
+ if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_ROOM)) {
+ try {
+ $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_ROOM);
+ $share = $provider->getShareByToken($token);
+ } catch (ProviderException $e) {
+ } catch (ShareNotFound $e) {
+ }
+ }
+
if ($share === null) {
throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
}
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index 7106e22b264..1125cae9565 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -2165,6 +2165,56 @@ class ManagerTest extends \Test\TestCase {
$this->assertSame($share, $ret);
}
+ public function testGetShareByTokenRoom() {
+ $this->config
+ ->expects($this->once())
+ ->method('getAppValue')
+ ->with('core', 'shareapi_allow_links', 'yes')
+ ->willReturn('no');
+
+ $factory = $this->createMock(IProviderFactory::class);
+
+ $manager = new Manager(
+ $this->logger,
+ $this->config,
+ $this->secureRandom,
+ $this->hasher,
+ $this->mountManager,
+ $this->groupManager,
+ $this->l,
+ $this->l10nFactory,
+ $factory,
+ $this->userManager,
+ $this->rootFolder,
+ $this->eventDispatcher,
+ $this->mailer,
+ $this->urlGenerator,
+ $this->defaults
+ );
+
+ $share = $this->createMock(IShare::class);
+
+ $roomShareProvider = $this->createMock(IShareProvider::class);
+
+ $factory->expects($this->any())
+ ->method('getProviderForType')
+ ->will($this->returnCallback(function($shareType) use ($roomShareProvider) {
+ if ($shareType !== \OCP\Share::SHARE_TYPE_ROOM) {
+ throw new Exception\ProviderException();
+ }
+
+ return $roomShareProvider;
+ }));
+
+ $roomShareProvider->expects($this->once())
+ ->method('getShareByToken')
+ ->with('token')
+ ->willReturn($share);
+
+ $ret = $manager->getShareByToken('token');
+ $this->assertSame($share, $ret);
+ }
+
public function testGetShareByTokenWithException() {
$this->config
->expects($this->once())