summaryrefslogtreecommitdiffstats
path: root/lib/Controller/FilesIntegrationController.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-09-30 11:40:01 +0200
committerJoas Schilling <coding@schilljs.com>2021-04-13 10:16:48 +0200
commit75f09c8216f51b0a20f2a2e151c80f517204d80c (patch)
treeccdd1a3a4b148ae49da740b65eb0d69f5671628f /lib/Controller/FilesIntegrationController.php
parent73be7bece9f118aedd2518bafa08afb560f82edc (diff)
Also allow accessing file conversations when access is possible via external storage or groupfolder
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Controller/FilesIntegrationController.php')
-rw-r--r--lib/Controller/FilesIntegrationController.php49
1 files changed, 4 insertions, 45 deletions
diff --git a/lib/Controller/FilesIntegrationController.php b/lib/Controller/FilesIntegrationController.php
index b2f4c07b2..84db07a7a 100644
--- a/lib/Controller/FilesIntegrationController.php
+++ b/lib/Controller/FilesIntegrationController.php
@@ -45,7 +45,6 @@ use OCP\IUser;
use OCP\IUserSession;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager as IShareManager;
-use OCP\Share\IShare;
class FilesIntegrationController extends OCSController {
@@ -134,27 +133,15 @@ class FilesIntegrationController extends OCSController {
}
- $share = $this->util->getAnyPublicShareOfFileOwnedByUserOrAnyDirectShareOfFileAccessibleByUser($fileId, $currentUser->getUID());
- $groupFolder = null;
- if (!$share) {
- $groupFolder = $this->util->getGroupFolderNode($fileId, $currentUser->getUID());
- if (!$groupFolder) {
- throw new OCSNotFoundException($this->l->t('File is not shared, or shared but not with the user'));
- }
+ $node = $this->util->getAnyNodeOfFileAccessibleByUser($fileId, $currentUser->getUID());
+ if ($node === null) {
+ throw new OCSNotFoundException($this->l->t('File is not shared, or shared but not with the user'));
}
try {
$room = $this->manager->getRoomByObject('file', $fileId);
} catch (RoomNotFoundException $e) {
- if ($share) {
- try {
- $name = $this->getFileName($share, $fileId);
- } catch (NotFoundException $e) {
- throw new OCSNotFoundException($this->l->t('File is not shared, or shared but not with the user'));
- }
- } else {
- $name = $groupFolder->getName();
- }
+ $name = $node->getName();
$name = $this->roomService->prepareConversationName($name);
$room = $this->roomService->createConversation(Room::PUBLIC_CALL, $name, null, 'file', $fileId);
}
@@ -244,32 +231,4 @@ class FilesIntegrationController extends OCSController {
'userDisplayName' => $currentUserDisplayName,
]);
}
-
- /**
- * Returns the name of the file in the share.
- *
- * If the given share itself is a file its name is returned; otherwise the
- * file is looked for in the given shared folder and its name is returned.
- *
- * @param IShare $share
- * @param string $fileId
- * @return string
- * @throws NotFoundException
- */
- private function getFileName(IShare $share, string $fileId): string {
- $node = $share->getNode();
-
- if ($node->getType() === FileInfo::TYPE_FILE) {
- return $node->getName();
- }
-
- $fileById = $node->getById($fileId);
-
- if (empty($fileById)) {
- throw new NotFoundException('File not found in share');
- }
-
- $file = array_shift($fileById);
- return $file->getName();
- }
}