2
0

API: GetSettings

This commit is contained in:
glax 2023-05-21 16:46:34 +02:00
parent e9db7cfacc
commit e2afc09c4a

View File

@ -146,6 +146,36 @@ app.MapGet("/TaskDequeue", (TrangaTask.Task task, string? connectorName, string?
return JsonSerializer.Serialize("Success");
});
app.MapGet("/Settings", () => JsonSerializer.Serialize(taskManager.settings));
app.MapGet("/Settings", () =>
{
return JsonSerializer.Serialize(new Settings(taskManager.settings));
});
app.Run();
app.Run();
struct Settings
{
public Komga? komga { get; set; }
public string downloadLocation { get; set; }
public string settingsFilePath { get; set; }
public Settings(TaskManager.SettingsData data)
{
this.settingsFilePath = data.settingsFilePath;
this.downloadLocation = data.downloadLocation;
this.komga = data.komga;
}
public Settings(string downloadLocation, string settingsFilePath, Komga komga)
{
this.downloadLocation = downloadLocation;
this.settingsFilePath = settingsFilePath;
this.komga = komga;
}
public void Update(string? newDownloadLocation = null, string? newSettingsFilePath = null, Komga? newKomga= null)
{
this.downloadLocation = newDownloadLocation ?? this.downloadLocation;
this.settingsFilePath = newSettingsFilePath ?? this.settingsFilePath;
this.komga = newKomga ?? this.komga;
}
}