3131use OCA \Activity \Extension \Files ;
3232use OCA \Activity \Extension \Files_Sharing ;
3333use OCP \Activity \IManager ;
34+ use OCP \Constants ;
3435use OCP \Files \Config \IUserMountCache ;
3536use OCP \Files \IRootFolder ;
3637use OCP \Files \Mount \IMountPoint ;
@@ -1251,8 +1252,10 @@ private function getAffectedUsersFromCachedMounts(int $fileId): array {
12511252 */
12521253 private function getUnrelatedUsers (int $ fileId , array $ cachedMounts ): array {
12531254 /** @var \OCA\GroupFolders\ACL\RuleManager $ruleManager */
1255+ /** @var \OCA\GroupFolders\Folder\FolderManager $folderManager */
12541256 try {
12551257 $ ruleManager = \OC ::$ server ->get (\OCA \GroupFolders \ACL \RuleManager::class);
1258+ $ folderManager = \OC ::$ server ->get (\OCA \GroupFolders \Folder \FolderManager::class);
12561259 } catch (\Exception $ e ) {
12571260 return []; // if we have no access to RuleManager, we cannot filter unrelated users
12581261 }
@@ -1279,18 +1282,24 @@ private function getUnrelatedUsers(int $fileId, array $cachedMounts): array {
12791282 try {
12801283 $ node = $ this ->rootFolder ->get ($ fullPath );
12811284 $ mountPoint = $ node ->getMountPoint ();
1282- $ folderId = $ mountPoint ->getFolderId ();
1285+
1286+ if (!$ mountPoint instanceof \OCA \GroupFolders \Mount \GroupMountPoint
1287+ || !$ folderManager ->getFolderAclEnabled ($ mountPoint ->getFolderId ())) {
1288+ continue ; // acl are disable
1289+ }
1290+
1291+ $ folderPath = $ mountPoint ->getSourcePath ();
12831292 $ path = substr ($ fullPath , strlen ($ mountPoint ->getMountPoint ()));
12841293 } catch (\Exception $ e ) {
12851294 // in case of issue during the process, we can imagine the user have no access to the file
1286- $ usersToCheck [] = $ fullPath ;
1295+ $ usersToCheck [] = $ cachedMount [ ' userId ' ] ;
12871296 continue ; // we'll catch rules on next user with access to the file
12881297 }
12891298
12901299 // we generate a list of path from top level of group folder to the file itself to get all rules
1291- $ paths = [' __groupfolders/ ' . $ folderId ];
1300+ $ paths = [$ folderPath ];
12921301 while ($ path !== '' ) {
1293- $ paths [] = ' __groupfolders/ ' . $ folderId . '/ ' . $ path ;
1302+ $ paths [] = $ folderPath . '/ ' . $ path ;
12941303 $ path = dirname ($ path );
12951304 if ($ path === '. ' || $ path === '/ ' ) {
12961305 $ path = '' ;
@@ -1320,7 +1329,7 @@ private function getUnrelatedUsers(int $fileId, array $cachedMounts): array {
13201329 // that might not have access to fileId
13211330 foreach ($ rules as $ rule ) {
13221331 if (($ rule ->getMask () & 1 ) === 0
1323- || ($ rule ->getPermissions () & 1 ) !== 0 ) {
1332+ || ($ rule ->getPermissions () & Constants:: PERMISSION_READ ) !== 0 ) {
13241333 continue ; // not interested of rules with 'mask' not including read capability (1), or if 'permission' does
13251334 }
13261335
@@ -1351,15 +1360,14 @@ private function getUnrelatedUsers(int $fileId, array $cachedMounts): array {
13511360 }
13521361
13531362
1354- // now that we have a list of 'unstable' users, we confirm they have no access to the file
1363+ // now that we have a list of eventuals filtered users, we confirm they have no access to the file
13551364 $ filteredUsers = [];
13561365 foreach ($ usersToCheck as $ userId ) {
13571366 try {
13581367 $ node = $ this ->rootFolder ->get ($ cachedPath [$ userId ]);
13591368 if ($ node ->isReadable ()) {
13601369 continue ; // overkill ? as rootFolder->get() would throw an exception if file is not available
13611370 }
1362-
13631371 } catch (\Exception $ e ) {
13641372 }
13651373
0 commit comments