feat: Settings in Datenbank speichern statt localStorage
- Neue Spalte 'settings' in users-Tabelle (Migration via TryAddColumn) - SettingsEndpoint: GET/PUT /api/settings - DatabaseService: GetUserSettings() + UpdateUserSettings() - Frontend: currentSettings als globaler State in app.js - settings-page.js: localStorage komplett entfernt, nutzt API - Settings werden beim App-Start aus DB geladen und angewendet
This commit is contained in:
1 parent
aac10901fa
commit
a0752ea492
8 files changed
+102
-43
No files matched your search
@@ -162,6 +162,7 @@ public class DatabaseService
|
||||
TryAddColumn(conn, "agents", "user_id", "TEXT");
|
||||
TryAddColumn(conn, "users", "is_admin", "INTEGER NOT NULL DEFAULT 0");
|
||||
TryAddColumn(conn, "users", "persona", "TEXT");
|
||||
TryAddColumn(conn, "users", "settings", "TEXT");
|
||||
|
||||
conn.Execute(@"
|
||||
CREATE TABLE IF NOT EXISTS agent_skills (
|
||||
@@ -792,6 +793,22 @@ public class DatabaseService
|
||||
new { userId, displayName, persona, now = DateTime.UtcNow.ToString("o") });
|
||||
}
|
||||
|
||||
public async Task<string> GetUserSettings(string userId)
|
||||
{
|
||||
using var conn = CreateConnection();
|
||||
return await conn.QuerySingleOrDefaultAsync<string>(
|
||||
"SELECT settings FROM users WHERE user_id = @userId",
|
||||
new { userId });
|
||||
}
|
||||
|
||||
public async Task UpdateUserSettings(string userId, string settings)
|
||||
{
|
||||
using var conn = CreateConnection();
|
||||
await conn.ExecuteAsync(
|
||||
"UPDATE users SET settings = @settings, updated_at = @now WHERE user_id = @userId",
|
||||
new { userId, settings, now = DateTime.UtcNow.ToString("o") });
|
||||
}
|
||||
|
||||
// ── Telegram ──
|
||||
|
||||
public async Task<string> CreateTelegramLinkCode(string userId, string sessionId, string agentId)
|
||||
|
||||
Reference in new issue
Block a user