Set parentId=0 already in DB layer, not in controller

This commit is contained in:
ig 2023-03-08 13:33:55 +01:00
parent e6fa2933b5
commit faf35be6cf
2 changed files with 5 additions and 4 deletions

View File

@ -174,8 +174,7 @@ public class Controller
using var db = Db.Connect(); using var db = Db.Connect();
var folders = db var folders = db
.GetDirectlyAccessibleFolders(caller) .GetDirectlyAccessibleFolders(caller) // ReSharper disable once AccessToDisposedClosure
.Do(f => f.ParentId = 0) // ReSharper disable once AccessToDisposedClosure
.Select(f => PopulateChildren(db, f)); .Select(f => PopulateChildren(db, f));
var installations = db.GetDirectlyAccessibleInstallations(caller); var installations = db.GetDirectlyAccessibleInstallations(caller);

View File

@ -111,7 +111,8 @@ public partial class Db : IDisposable
.Where(r => r.UserId == user.Id) .Where(r => r.UserId == user.Id)
.Select(r => r.InstallationId) .Select(r => r.InstallationId)
.Select(GetInstallationById) .Select(GetInstallationById)
.NotNull(); .NotNull()
.Do(i => i.ParentId = 0); // hide inaccessible parents from calling user
} }
public IEnumerable<Folder> GetDirectlyAccessibleFolders(User user) public IEnumerable<Folder> GetDirectlyAccessibleFolders(User user)
@ -120,7 +121,8 @@ public partial class Db : IDisposable
.Where(r => r.UserId == user.Id) .Where(r => r.UserId == user.Id)
.Select(r => r.FolderId) .Select(r => r.FolderId)
.Select(GetFolderById) .Select(GetFolderById)
.NotNull(); .NotNull()
.Do(i => i.ParentId = 0); // hide inaccessible parents from calling user;
} }
public Result AddToAccessibleInstallations(Int64 userId, Int64 updatedInstallationId) public Result AddToAccessibleInstallations(Int64 userId, Int64 updatedInstallationId)