Switched to database scheme seperation from MoonCores SingleDb. Updated mooncore versions. Updating to correct Async naming
This commit is contained in:
@@ -14,7 +14,7 @@ public class ApiKeyAuthService
|
||||
ApiKeyRepository = apiKeyRepository;
|
||||
}
|
||||
|
||||
public async Task<bool> Validate(ClaimsPrincipal? principal)
|
||||
public async Task<bool> ValidateAsync(ClaimsPrincipal? principal)
|
||||
{
|
||||
// Ignore malformed claims principal
|
||||
if (principal is not { Identity.IsAuthenticated: true })
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ApplicationService
|
||||
Host = host;
|
||||
}
|
||||
|
||||
public Task<string> GetOsName()
|
||||
public Task<string> GetOsNameAsync()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
@@ -58,7 +58,7 @@ public class ApplicationService
|
||||
return Task.FromResult("N/A");
|
||||
}
|
||||
|
||||
public async Task<long> GetMemoryUsage()
|
||||
public async Task<long> GetMemoryUsageAsync()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
@@ -87,14 +87,14 @@ public class ApplicationService
|
||||
}
|
||||
}
|
||||
|
||||
public Task<TimeSpan> GetUptime()
|
||||
public Task<TimeSpan> GetUptimeAsync()
|
||||
{
|
||||
var process = Process.GetCurrentProcess();
|
||||
var uptime = DateTime.Now - process.StartTime;
|
||||
return Task.FromResult(uptime);
|
||||
}
|
||||
|
||||
public Task<int> GetCpuUsage()
|
||||
public Task<int> GetCpuUsageAsync()
|
||||
{
|
||||
var process = Process.GetCurrentProcess();
|
||||
var cpuTime = process.TotalProcessorTime;
|
||||
@@ -105,7 +105,7 @@ public class ApplicationService
|
||||
return Task.FromResult(cpuUsage);
|
||||
}
|
||||
|
||||
public Task Shutdown()
|
||||
public Task ShutdownAsync()
|
||||
{
|
||||
Logger.LogCritical("Restart of api server has been requested");
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class FrontendService
|
||||
ThemeRepository = themeRepository;
|
||||
}
|
||||
|
||||
public Task<FrontendConfiguration> GetConfiguration()
|
||||
public Task<FrontendConfiguration> GetConfigurationAsync()
|
||||
{
|
||||
var configuration = new FrontendConfiguration()
|
||||
{
|
||||
@@ -51,7 +51,7 @@ public class FrontendService
|
||||
return Task.FromResult(configuration);
|
||||
}
|
||||
|
||||
public async Task<string> GenerateIndexHtml() // TODO: Cache
|
||||
public async Task<string> GenerateIndexHtmlAsync() // TODO: Cache
|
||||
{
|
||||
// Load requested theme
|
||||
var theme = await ThemeRepository
|
||||
@@ -70,7 +70,7 @@ public class FrontendService
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
|
||||
return await ComponentHelper.RenderComponent<FrontendPage>(
|
||||
return await ComponentHelper.RenderToHtmlAsync<FrontendPage>(
|
||||
ServiceProvider,
|
||||
parameters =>
|
||||
{
|
||||
@@ -82,7 +82,7 @@ public class FrontendService
|
||||
);
|
||||
}
|
||||
|
||||
public async Task<Stream> GenerateZip() // TODO: Rework to be able to extract everything successfully
|
||||
public async Task<Stream> GenerateZipAsync() // TODO: Rework to be able to extract everything successfully
|
||||
{
|
||||
// We only allow the access to this function when we are actually hosting the frontend
|
||||
if (!Configuration.Frontend.EnableHosting)
|
||||
@@ -109,16 +109,16 @@ public class FrontendService
|
||||
var zipArchive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true);
|
||||
|
||||
// Add wasm application
|
||||
await ArchiveFsItem(zipArchive, wasmPath, wasmPath);
|
||||
await ArchiveFsItemAsync(zipArchive, wasmPath, wasmPath);
|
||||
|
||||
// Add blazor files
|
||||
await ArchiveFsItem(zipArchive, blazorPath, blazorPath, "_framework/");
|
||||
await ArchiveFsItemAsync(zipArchive, blazorPath, blazorPath, "_framework/");
|
||||
|
||||
// Add frontend.json
|
||||
var frontendConfig = await GetConfiguration();
|
||||
var frontendConfig = await GetConfigurationAsync();
|
||||
frontendConfig.HostEnvironment = "Static";
|
||||
var frontendJson = JsonSerializer.Serialize(frontendConfig);
|
||||
await ArchiveText(zipArchive, "frontend.json", frontendJson);
|
||||
await ArchiveTextAsync(zipArchive, "frontend.json", frontendJson);
|
||||
|
||||
// Finish zip archive and reset stream so the code calling this function can process it
|
||||
zipArchive.Dispose();
|
||||
@@ -128,7 +128,7 @@ public class FrontendService
|
||||
return memoryStream;
|
||||
}
|
||||
|
||||
private async Task ArchiveFsItem(ZipArchive archive, string path, string prefixToRemove, string prefixToAdd = "")
|
||||
private async Task ArchiveFsItemAsync(ZipArchive archive, string path, string prefixToRemove, string prefixToAdd = "")
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
@@ -147,17 +147,17 @@ public class FrontendService
|
||||
else
|
||||
{
|
||||
foreach (var directoryItem in Directory.EnumerateFileSystemEntries(path))
|
||||
await ArchiveFsItem(archive, directoryItem, prefixToRemove, prefixToAdd);
|
||||
await ArchiveFsItemAsync(archive, directoryItem, prefixToRemove, prefixToAdd);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ArchiveText(ZipArchive archive, string path, string content)
|
||||
private async Task ArchiveTextAsync(ZipArchive archive, string path, string content)
|
||||
{
|
||||
var data = Encoding.UTF8.GetBytes(content);
|
||||
await ArchiveBytes(archive, path, data);
|
||||
await ArchiveBytesAsync(archive, path, data);
|
||||
}
|
||||
|
||||
private async Task ArchiveBytes(ZipArchive archive, string path, byte[] bytes)
|
||||
private async Task ArchiveBytesAsync(ZipArchive archive, string path, byte[] bytes)
|
||||
{
|
||||
var entry = archive.CreateEntry(path);
|
||||
await using var dataStream = entry.Open();
|
||||
|
||||
@@ -33,7 +33,7 @@ public class MetricsBackgroundService : BackgroundService
|
||||
Metrics = metrics.ToArray();
|
||||
}
|
||||
|
||||
private async Task Initialize()
|
||||
private async Task InitializeAsync()
|
||||
{
|
||||
Logger.LogDebug(
|
||||
"Initializing metrics: {names}",
|
||||
@@ -41,12 +41,12 @@ public class MetricsBackgroundService : BackgroundService
|
||||
);
|
||||
|
||||
foreach (var metric in Metrics)
|
||||
await metric.Initialize(Meter);
|
||||
await metric.InitializeAsync(Meter);
|
||||
}
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
await Initialize();
|
||||
await InitializeAsync();
|
||||
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
@@ -56,7 +56,7 @@ public class MetricsBackgroundService : BackgroundService
|
||||
{
|
||||
try
|
||||
{
|
||||
await metric.Run(scope.ServiceProvider, stoppingToken);
|
||||
await metric.RunAsync(scope.ServiceProvider, stoppingToken);
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ public class UserAuthService
|
||||
Extensions = extensions;
|
||||
}
|
||||
|
||||
public async Task<bool> Sync(ClaimsPrincipal? principal)
|
||||
public async Task<bool> SyncAsync(ClaimsPrincipal? principal)
|
||||
{
|
||||
// Ignore malformed claims principal
|
||||
if (principal is not { Identity.IsAuthenticated: true })
|
||||
@@ -107,7 +107,7 @@ public class UserAuthService
|
||||
// Call extensions
|
||||
foreach (var extension in Extensions)
|
||||
{
|
||||
var result = await extension.Sync(user, principal);
|
||||
var result = await extension.SyncAsync(user, principal);
|
||||
|
||||
if (!result) // Exit immediately if result is false
|
||||
return false;
|
||||
@@ -116,7 +116,7 @@ public class UserAuthService
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> Validate(ClaimsPrincipal? principal)
|
||||
public async Task<bool> ValidateAsync(ClaimsPrincipal? principal)
|
||||
{
|
||||
// Ignore malformed claims principal
|
||||
if (principal is not { Identity.IsAuthenticated: true })
|
||||
@@ -157,7 +157,7 @@ public class UserAuthService
|
||||
// Call extensions
|
||||
foreach (var extension in Extensions)
|
||||
{
|
||||
var result = await extension.Validate(user, principal);
|
||||
var result = await extension.ValidateAsync(user, principal);
|
||||
|
||||
if (!result) // Exit immediately if result is false
|
||||
return false;
|
||||
|
||||
@@ -19,11 +19,11 @@ public class UserDeletionService
|
||||
Handlers = handlers.ToArray();
|
||||
}
|
||||
|
||||
public async Task<UserDeleteValidationResult> Validate(User user)
|
||||
public async Task<UserDeleteValidationResult> ValidateAsync(User user)
|
||||
{
|
||||
foreach (var handler in Handlers)
|
||||
{
|
||||
var result = await handler.Validate(user);
|
||||
var result = await handler.ValidateAsync(user);
|
||||
|
||||
if (!result.IsAllowed)
|
||||
return result;
|
||||
@@ -32,10 +32,10 @@ public class UserDeletionService
|
||||
return UserDeleteValidationResult.Allow();
|
||||
}
|
||||
|
||||
public async Task Delete(User user, bool force)
|
||||
public async Task DeleteAsync(User user, bool force)
|
||||
{
|
||||
foreach (var handler in Handlers)
|
||||
await handler.Delete(user, force);
|
||||
await handler.DeleteAsync(user, force);
|
||||
|
||||
await UserRepository.RemoveAsync(user);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user