feat: API Key pro Agent statt pro User

- Neue Tabelle agent_api_keys (user_id, agent_id, key_id)
- Migration: bestehende selected_api_key_id auf alle Agents verteilt
- Backend: GetAgentApiKeyRecord(userId, agentId) in Chat, Telegram, Cronjobs
- Endpoints: select/selected mit ?agentId Query-Parameter
- Frontend: currentAgentId aus Session, alle Key-Calls agent-aware
- DeleteApiKey bereinigt agent_api_keys statt users.selected_api_key_id
This commit is contained in:
Meleki committed 2026-03-14 21:41:27 +01:00
1 parent b04b1a2cf9
commit 1effc6d00f
10 files changed
+128 -43

No files matched your search

+2 -2
View File
@@ -427,9 +427,9 @@ public partial class DatabaseService
await conn.ExecuteAsync(
"UPDATE scanned_keys SET adopted_api_key_id = NULL WHERE adopted_api_key_id = @keyId",
new { keyId });
// User die diesen Key ausgewählt haben zurücksetzen
// Agent-Key-Zuordnungen die auf diesen Key verweisen löschen
await conn.ExecuteAsync(
"UPDATE users SET selected_api_key_id = NULL WHERE selected_api_key_id = @keyId",
"DELETE FROM agent_api_keys WHERE key_id = @keyId",
new { keyId });
await conn.ExecuteAsync("DELETE FROM api_keys WHERE key_id = @keyId", new { keyId });
}