Fix AccessibleFolders

This commit is contained in:
ig 2023-03-17 09:11:26 +01:00
parent 4a19ebd49c
commit 44e183a9f1
2 changed files with 10 additions and 4 deletions

View File

@ -74,7 +74,7 @@ public static class FolderMethods
public static Boolean IsRelativeRoot(this Folder folder) 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) public static Boolean WasMoved(this Folder folder)

View File

@ -27,7 +27,7 @@ public static class UserMethods
{ {
return user return user
.DirectlyAccessibleFolders() .DirectlyAccessibleFolders()
.SelectMany(f => f.DescendantFolders()) .SelectMany(f => f.DescendantFolders().Prepend(f))
.Distinct(); .Distinct();
// Distinct because the user might have direct access // Distinct because the user might have direct access
@ -51,7 +51,7 @@ public static class UserMethods
.Select(r => r.InstallationId) .Select(r => r.InstallationId)
.Select(Db.GetInstallationById) .Select(Db.GetInstallationById)
.NotNull() .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<Folder> DirectlyAccessibleFolders(this User user) public static IEnumerable<Folder> DirectlyAccessibleFolders(this User user)
@ -62,7 +62,7 @@ public static class UserMethods
.Select(r => r.FolderId) .Select(r => r.FolderId)
.Select(Db.GetFolderById) .Select(Db.GetFolderById)
.NotNull() .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<User> ChildUsers(this User parent) public static IEnumerable<User> ChildUsers(this User parent)
@ -173,6 +173,12 @@ public static class UserMethods
.Contains(user); .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) public static String Salt(this User user)
{ {
// + id => salt unique per user // + id => salt unique per user