From faf35be6cfe5bb7bee25ca44ded2610342796aea Mon Sep 17 00:00:00 2001 From: ig Date: Wed, 8 Mar 2023 13:33:55 +0100 Subject: [PATCH] Set parentId=0 already in DB layer, not in controller --- csharp/App/Backend/Controllers/Controller.cs | 3 +-- csharp/App/Backend/Database/Db.cs | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/csharp/App/Backend/Controllers/Controller.cs b/csharp/App/Backend/Controllers/Controller.cs index 91c5e012e..b7935922b 100644 --- a/csharp/App/Backend/Controllers/Controller.cs +++ b/csharp/App/Backend/Controllers/Controller.cs @@ -174,8 +174,7 @@ public class Controller using var db = Db.Connect(); var folders = db - .GetDirectlyAccessibleFolders(caller) - .Do(f => f.ParentId = 0) // ReSharper disable once AccessToDisposedClosure + .GetDirectlyAccessibleFolders(caller) // ReSharper disable once AccessToDisposedClosure .Select(f => PopulateChildren(db, f)); var installations = db.GetDirectlyAccessibleInstallations(caller); diff --git a/csharp/App/Backend/Database/Db.cs b/csharp/App/Backend/Database/Db.cs index f8ff601bd..1625c128f 100644 --- a/csharp/App/Backend/Database/Db.cs +++ b/csharp/App/Backend/Database/Db.cs @@ -111,7 +111,8 @@ public partial class Db : IDisposable .Where(r => r.UserId == user.Id) .Select(r => r.InstallationId) .Select(GetInstallationById) - .NotNull(); + .NotNull() + .Do(i => i.ParentId = 0); // hide inaccessible parents from calling user } public IEnumerable GetDirectlyAccessibleFolders(User user) @@ -120,7 +121,8 @@ public partial class Db : IDisposable .Where(r => r.UserId == user.Id) .Select(r => r.FolderId) .Select(GetFolderById) - .NotNull(); + .NotNull() + .Do(i => i.ParentId = 0); // hide inaccessible parents from calling user; } public Result AddToAccessibleInstallations(Int64 userId, Int64 updatedInstallationId)