Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions lib/FilesHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,9 @@ private function getAffectedUsersFromCachedMounts(int $fileId): array {
'provider' => str_replace('\\\\', '\\', $mount->getMountProvider()),
'path' => $mount->getPath(),
'visiblePath' => $this->getVisiblePath($mount->getPath()),
'storageId' => $mount->getStorageId()
'storageId' => $mount->getStorageId(),
'internalPath' => $mount->getInternalPath(),
'rootInternalPath' => $mount->getRootInternalPath(),
];
}

Expand Down Expand Up @@ -1281,6 +1283,8 @@ private function getUnrelatedUsers(int $fileId, array $cachedMounts): array {
return []; // if we have no access to RuleManager, we cannot filter unrelated users
}

$groupFolderAclStatus = [];

/** @var \OCA\GroupFolders\ACL\Rule[] $rules */
$rules = $knownRules = $knownGroupRules = $usersToCheck = $cachedPath = [];
foreach ($cachedMounts as $cachedMount) {
Expand All @@ -1301,16 +1305,21 @@ private function getUnrelatedUsers(int $fileId, array $cachedMounts): array {
if (!array_key_exists($cachedMount['visiblePath'], $knownRules[$storageId])) {
// we need mountPoint and folderId to generate the correct path
try {
$node = $this->rootFolder->get($fullPath);
$mountPoint = $node->getMountPoint();
// only check for groupfolders
if (!str_starts_with($cachedMount['rootInternalPath'], '__groupfolders')) {
continue;
}

if (!$mountPoint instanceof \OCA\GroupFolders\Mount\GroupMountPoint
|| !$folderManager->getFolderAclEnabled($mountPoint->getFolderId())) {
$folderId = (int)basename($cachedMount['rootInternalPath']);
if (!isset($groupFolderAclStatus[$folderId])) {
$groupFolderAclStatus[$folderId] = $folderManager->getFolderAclEnabled($folderId);
}
if (!$groupFolderAclStatus[$folderId]) {
continue; // acl are disable
}

$folderPath = $mountPoint->getSourcePath();
$path = substr($fullPath, strlen($mountPoint->getMountPoint()));
$folderPath = '/' . $cachedMount['rootInternalPath'];
$path = $cachedMount['internalPath'];
} catch (\Exception $e) {
// in case of issue during the process, we can imagine the user have no access to the file
$usersToCheck[] = $cachedMount['userId'];
Expand Down
Loading