refactor: Backend deduplizieren – 13 Dateien, -528 Zeilen netto
ChatContext: 3 identische Context-Klassen (PreparerContext, ReviewContext, FinalizerContext) zu einer SubAgentContext-Klasse zusammengefasst. ChatService: 3x40 Zeilen Sub-Agent-Setup durch BuildSubAgentContext() ersetzt. AnthropicService: 5 Hilfsmethoden extrahiert – ExtractWebSearchSources(), TruncateToolResult(), AddToolsToPayload(), ParseServerToolUse(), TrackUsage(). WorkspaceEndpoint: 5 Session/Agent-Endpoint-Paare durch generische Core-Handler mit basePath-Parameter ersetzt. Ungenutzte rmdir-Endpoints entfernt. AgentEndpoint: Doppeltes Agent-DTO-Mapping durch MapAgentList() ersetzt. SessionEndpoint: Doppelte Session/Agent-Auflösung durch ResolvePromptContext() ersetzt. DatabaseService: Toten Code entfernt (SetSessionTelegramChatId, ClearSessionTelegramChatId, GetSessions, GetUserSessions). ConvertDataUrlToWebP und ResizeDataUrlToWebP zu einer Methode zusammengefasst. TelegramEndpoint: Bot-DTO-Mapping durch MapBotResponse() dedupliziert. KreaEndpoint + SkillEndpoint: Thumbnail-Generierung in ImageService.GenerateThumbnail() extrahiert, SixLabors-Imports aus Endpoints entfernt. CronjobEndpoint: 7x ctx.Items[UserId] durch ctx.GetUserId() ersetzt.
This commit is contained in:
1 parent
0097ce69db
commit
dcedbaa074
13 files changed
+447
-975
No files matched your search
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Gott.Models;
|
||||
using Gott.Extensions;
|
||||
using Gott.Services;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -15,14 +16,14 @@ public static class CronjobEndpoint
|
||||
{
|
||||
app.MapGet("/api/cronjobs", async (HttpContext ctx, DatabaseService db) =>
|
||||
{
|
||||
var userId = ctx.Items["UserId"]?.ToString();
|
||||
var userId = ctx.GetUserId();
|
||||
var cronjobs = await db.GetCronjobs(userId);
|
||||
return Results.Ok(cronjobs);
|
||||
});
|
||||
|
||||
app.MapGet("/api/cronjobs/{id}", async (string id, HttpContext ctx, DatabaseService db) =>
|
||||
{
|
||||
var userId = ctx.Items["UserId"]?.ToString();
|
||||
var userId = ctx.GetUserId();
|
||||
var cronjob = await db.GetCronjob(id);
|
||||
if (cronjob == null || cronjob.UserId != userId) return Results.NotFound();
|
||||
return Results.Ok(cronjob);
|
||||
@@ -30,7 +31,7 @@ public static class CronjobEndpoint
|
||||
|
||||
app.MapPost("/api/cronjobs", async (HttpContext ctx, DatabaseService db) =>
|
||||
{
|
||||
var userId = ctx.Items["UserId"]?.ToString();
|
||||
var userId = ctx.GetUserId();
|
||||
var body = await JsonSerializer.DeserializeAsync<JsonElement>(ctx.Request.Body);
|
||||
|
||||
var name = body.TryGetProperty("name", out var n) ? n.GetString() ?? "" : "";
|
||||
@@ -79,7 +80,7 @@ public static class CronjobEndpoint
|
||||
|
||||
app.MapPut("/api/cronjobs/{id}", async (string id, HttpContext ctx, DatabaseService db) =>
|
||||
{
|
||||
var userId = ctx.Items["UserId"]?.ToString();
|
||||
var userId = ctx.GetUserId();
|
||||
var existing = await db.GetCronjob(id);
|
||||
if (existing == null || existing.UserId != userId) return Results.NotFound();
|
||||
|
||||
@@ -134,7 +135,7 @@ public static class CronjobEndpoint
|
||||
|
||||
app.MapDelete("/api/cronjobs/{id}", async (string id, HttpContext ctx, DatabaseService db) =>
|
||||
{
|
||||
var userId = ctx.Items["UserId"]?.ToString();
|
||||
var userId = ctx.GetUserId();
|
||||
var existing = await db.GetCronjob(id);
|
||||
if (existing == null || existing.UserId != userId) return Results.NotFound();
|
||||
|
||||
@@ -144,7 +145,7 @@ public static class CronjobEndpoint
|
||||
|
||||
app.MapPost("/api/cronjobs/{id}/toggle", async (string id, HttpContext ctx, DatabaseService db) =>
|
||||
{
|
||||
var userId = ctx.Items["UserId"]?.ToString();
|
||||
var userId = ctx.GetUserId();
|
||||
var existing = await db.GetCronjob(id);
|
||||
if (existing == null || existing.UserId != userId) return Results.NotFound();
|
||||
|
||||
@@ -158,7 +159,7 @@ public static class CronjobEndpoint
|
||||
|
||||
app.MapPost("/api/cronjobs/{id}/run", async (string id, HttpContext ctx, DatabaseService db, CronjobService cronjobService) =>
|
||||
{
|
||||
var userId = ctx.Items["UserId"]?.ToString();
|
||||
var userId = ctx.GetUserId();
|
||||
var existing = await db.GetCronjob(id);
|
||||
if (existing == null || existing.UserId != userId) return Results.NotFound();
|
||||
|
||||
|
||||
Reference in new issue
Block a user