mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2025-09-19 00:24:49 +02:00
.config
.run
.workdir
Agent
Common
Controller
Phantom.Controller
Phantom.Controller.Database
Phantom.Controller.Database.Postgres
Phantom.Controller.Minecraft
Phantom.Controller.Services
Agents
Events
Instances
Rpc
Users
Sessions
AuditLogManager.cs
PermissionManager.cs
Role.cs
RoleManager.cs
UserManager.cs
UserRoleManager.cs
ControllerServices.cs
ControllerState.cs
Phantom.Controller.Services.csproj
Docker
Utils
Web
.dockerignore
.gitattributes
.gitignore
AddMigration.bat
AddMigration.sh
Directory.Build.props
Directory.Build.targets
Dockerfile
LICENSE
Packages.props
PhantomPanel.sln
README.md
global.json
27 lines
884 B
C#
27 lines
884 B
C#
using System.Collections.Immutable;
|
|
using Phantom.Common.Data;
|
|
using Phantom.Common.Data.Web.AuditLog;
|
|
using Phantom.Common.Data.Web.Users;
|
|
using Phantom.Controller.Database;
|
|
using Phantom.Controller.Database.Repositories;
|
|
using Phantom.Controller.Services.Users.Sessions;
|
|
|
|
namespace Phantom.Controller.Services.Users;
|
|
|
|
sealed class AuditLogManager {
|
|
private readonly IDbContextProvider dbProvider;
|
|
|
|
public AuditLogManager(IDbContextProvider dbProvider) {
|
|
this.dbProvider = dbProvider;
|
|
}
|
|
|
|
public async Task<Result<ImmutableArray<AuditLogItem>, UserActionFailure>> GetMostRecentItems(LoggedInUser loggedInUser, int count) {
|
|
if (!loggedInUser.CheckPermission(Permission.ViewAudit)) {
|
|
return UserActionFailure.NotAuthorized;
|
|
}
|
|
|
|
await using var db = dbProvider.Lazy();
|
|
return await new AuditLogRepository(db).GetMostRecentItems(count, CancellationToken.None);
|
|
}
|
|
}
|