mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2024-11-21 23:42:45 +01:00
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);
|
|
}
|
|
}
|