From 44e183a9f1370b7ecbb593d9feae73bb55de8add Mon Sep 17 00:00:00 2001 From: ig Date: Fri, 17 Mar 2023 09:11:26 +0100 Subject: [PATCH] Fix AccessibleFolders --- csharp/App/Backend/DataTypes/Methods/Folder.cs | 2 +- csharp/App/Backend/DataTypes/Methods/User.cs | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/csharp/App/Backend/DataTypes/Methods/Folder.cs b/csharp/App/Backend/DataTypes/Methods/Folder.cs index b6543e53e..404410997 100644 --- a/csharp/App/Backend/DataTypes/Methods/Folder.cs +++ b/csharp/App/Backend/DataTypes/Methods/Folder.cs @@ -74,7 +74,7 @@ public static class FolderMethods public static Boolean IsRelativeRoot(this Folder folder) { - return folder.ParentId < 0; // root has ParentId 0 by definition + return folder.ParentId < 0; } public static Boolean WasMoved(this Folder folder) diff --git a/csharp/App/Backend/DataTypes/Methods/User.cs b/csharp/App/Backend/DataTypes/Methods/User.cs index 83905a911..f0d2c347f 100644 --- a/csharp/App/Backend/DataTypes/Methods/User.cs +++ b/csharp/App/Backend/DataTypes/Methods/User.cs @@ -27,7 +27,7 @@ public static class UserMethods { return user .DirectlyAccessibleFolders() - .SelectMany(f => f.DescendantFolders()) + .SelectMany(f => f.DescendantFolders().Prepend(f)) .Distinct(); // Distinct because the user might have direct access @@ -51,7 +51,7 @@ public static class UserMethods .Select(r => r.InstallationId) .Select(Db.GetInstallationById) .NotNull() - .Do(i => i.ParentId = -1); // hide inaccessible parents from calling user + .Do(i => i.ParentId = 0); // hide inaccessible parents from calling user } public static IEnumerable DirectlyAccessibleFolders(this User user) @@ -62,7 +62,7 @@ public static class UserMethods .Select(r => r.FolderId) .Select(Db.GetFolderById) .NotNull() - .Do(i => i.ParentId = -1); // hide inaccessible parents from calling user; + .Do(i => i.ParentId = 0); // hide inaccessible parents from calling user; } public static IEnumerable ChildUsers(this User parent) @@ -172,6 +172,12 @@ public static class UserMethods .Ancestors() .Contains(user); } + + public static Boolean IsRelativeRoot(this User user, Installation i) + { + // TODO: determine not by id but by accessibility + return i.ParentId < 0; + } public static String Salt(this User user) {