summaryrefslogtreecommitdiff
path: root/Services/SecurityService.cs
blob: 969525466cc2c79258411e700513347a6a8beafb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using Microsoft.EntityFrameworkCore;

namespace HyperBooru.Services;

public class SecurityService {
    private IDbContextFactory<HBContext> dbFactory;

    private Acl[] acls;

    public SecurityService(IDbContextFactory<HBContext> dbFactory) {
        this.dbFactory = dbFactory;
        Reload();
    }

    public void Reload() {
        using var db = dbFactory.CreateDbContext();
        acls = db.Acls
            .Include(a => a.Rules)
            .ThenInclude(r => r.Principal)
            .ToArray();
    }

    public IEnumerable<HBObject> Filter(IEnumerable<HBObject> objects, ulong permissions) {
        foreach(var obj in objects) {
        }

        return Enumerable.Empty<HBObject>();
    }
}