Refactor: Server-Settings von appsettings.json in DB-Tabelle (server_settings)
- Neuer ServerSettingsService: zentrale Settings in SQLite mit In-Memory-Cache - Auto-Migration: bestehende appsettings.Production.json wird einmalig in DB übernommen - Alle Services umgestellt: IConfiguration → ServerSettingsService (dynamisch, kein Neustart) - Port bleibt als einziges Setting in appsettings.Production.json (erfordert Neustart) - ServerSettingsEndpoint: liest/schreibt DB statt JSON-Datei, Port als Sonder-Setting - IConfiguration komplett entfernt aus allen Services (ChatService, ToolService, AnthropicService, OpenAiService, KreaService, TelegramService, KeyScannerService, GitHubEventScannerService) - AuthMiddleware: KreaApiKey dynamisch aus DB - appsettings.json bereinigt: nur noch Port und Logging - Dokumentation aktualisiert (ARCHITECTURE.md, ARCHITECTURE_QUICK.md, README.md)
This commit is contained in:
1 parent
542a031172
commit
122000487c
18 files changed
+389
-270
No files matched your search
@@ -10,7 +10,6 @@ using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.FileSystemGlobbing;
|
||||
using Microsoft.Extensions.FileSystemGlobbing.Abstractions;
|
||||
|
||||
@@ -18,12 +17,12 @@ namespace Gott.Services;
|
||||
|
||||
public class ToolService
|
||||
{
|
||||
private readonly IConfiguration _config;
|
||||
private readonly ServerSettingsService _settings;
|
||||
private IHttpClientFactory _httpFactory;
|
||||
|
||||
public ToolService(IConfiguration config)
|
||||
public ToolService(ServerSettingsService settings)
|
||||
{
|
||||
_config = config;
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public void SetHttpClientFactory(IHttpClientFactory httpFactory)
|
||||
@@ -31,9 +30,9 @@ public class ToolService
|
||||
_httpFactory = httpFactory;
|
||||
}
|
||||
|
||||
private int ExecuteTimeoutSeconds => _config.GetValue<int>("ExecuteTimeout", 180);
|
||||
public bool HasGitHubToken => !string.IsNullOrWhiteSpace(_config["GitHubToken"]);
|
||||
public bool HasSerperKey => !string.IsNullOrWhiteSpace(_config["SerperApiKey"]);
|
||||
private int ExecuteTimeoutSeconds => _settings.GetInt("ExecuteTimeout", 180);
|
||||
public bool HasGitHubToken => !string.IsNullOrWhiteSpace(_settings.Get("GitHubToken"));
|
||||
public bool HasSerperKey => !string.IsNullOrWhiteSpace(_settings.Get("SerperApiKey"));
|
||||
public const string AskUserChoiceToolName = "ask_user_choice";
|
||||
|
||||
/// <summary>
|
||||
@@ -858,7 +857,7 @@ public class ToolService
|
||||
|
||||
private async Task<string> ExecuteGitHubCodeSearch(JsonElement input, CancellationToken ct)
|
||||
{
|
||||
var token = _config["GitHubToken"] ?? "";
|
||||
var token = _settings.Get("GitHubToken");
|
||||
if (string.IsNullOrWhiteSpace(token))
|
||||
return "Fehler: Kein GitHubToken konfiguriert. Bitte in den Server-Einstellungen hinterlegen.";
|
||||
|
||||
@@ -961,7 +960,7 @@ public class ToolService
|
||||
|
||||
private async Task<string> ExecuteSerperWebSearch(JsonElement input, CancellationToken ct)
|
||||
{
|
||||
var apiKey = _config["SerperApiKey"] ?? "";
|
||||
var apiKey = _settings.Get("SerperApiKey");
|
||||
if (string.IsNullOrWhiteSpace(apiKey))
|
||||
return "Fehler: Kein SerperApiKey konfiguriert. Bitte in den Server-Einstellungen hinterlegen.";
|
||||
|
||||
|
||||
Reference in new issue
Block a user