diff --git a/lib/Chat/AutoComplete/SearchPlugin.php b/lib/Chat/AutoComplete/SearchPlugin.php index dcb303708de..c19b3188775 100644 --- a/lib/Chat/AutoComplete/SearchPlugin.php +++ b/lib/Chat/AutoComplete/SearchPlugin.php @@ -52,7 +52,7 @@ public function setContext(array $context): void { #[\Override] public function search($search, $limit, $offset, ISearchResult $searchResult): bool { if ($this->room->getObjectType() === 'file') { - $usersWithFileAccess = $this->util->getUsersWithAccessFile($this->room->getObjectId()); + $usersWithFileAccess = $this->util->getUsersWithAccessFile($this->room->getObjectId(), $this->userId); if (!empty($usersWithFileAccess)) { $users = []; foreach ($usersWithFileAccess as $userId) { diff --git a/lib/Controller/FilesIntegrationController.php b/lib/Controller/FilesIntegrationController.php index c5d276ed1d3..67928369a41 100644 --- a/lib/Controller/FilesIntegrationController.php +++ b/lib/Controller/FilesIntegrationController.php @@ -104,7 +104,7 @@ public function getRoomByFileId(string $fileId): DataResponse { throw new OCSNotFoundException($this->l->t('File is not shared, or shared but not with the user')); } - $users = $this->util->getUsersWithAccessFile($fileId); + $users = $this->util->getUsersWithAccessFile($fileId, $currentUser->getUID()); if (count($users) <= 1 && !$this->util->canGuestsAccessFile($fileId)) { throw new OCSNotFoundException($this->l->t('File is not shared, or shared but not with the user')); } diff --git a/lib/Files/Util.php b/lib/Files/Util.php index 0f98479e5d2..4dad1e38771 100644 --- a/lib/Files/Util.php +++ b/lib/Files/Util.php @@ -35,9 +35,10 @@ public function __construct( /** * @return string[] */ - public function getUsersWithAccessFile(string $fileId): array { + public function getUsersWithAccessFile(string $fileId, string $userId): array { if (!isset($this->accessLists[$fileId])) { - $nodes = $this->rootFolder->getById((int)$fileId); + $userFolder = $this->rootFolder->getUserFolder($userId); + $nodes = $userFolder->getById((int)$fileId); if (empty($nodes)) { return []; @@ -64,7 +65,7 @@ public function getUsersWithAccessFile(string $fileId): array { } public function canUserAccessFile(string $fileId, string $userId): bool { - return \in_array($userId, $this->getUsersWithAccessFile($fileId), true); + return \in_array($userId, $this->getUsersWithAccessFile($fileId, $userId), true); } public function canGuestsAccessFile(string $fileId): bool {