Files
gott/Program.cs
T
Meleki be29984b25 feat: Einzelne Nachrichten als Link teilen
Backend:
- SharedMessageRecord Model + shared_messages DB-Tabelle
- SharedEndpoint: POST /api/messages/{id}/share, GET /api/shared/{token},
  GET /api/shared (Liste), DELETE /api/shared/{token}
- Auth-Ausnahme für GET /api/shared/{token} (öffentlich ohne Login)
- DB-Methoden: CreateSharedMessage, GetSharedMessage, GetChainMessagesUpTo

Frontend:
- Share-Button (fa-share-alt) an jeder Nachricht
- Kontextmenü: Einzelnachricht oder mit Thread-Kontext teilen
- Link wird automatisch in Zwischenablage kopiert
- Öffentliche Shared-Page (#shared/{token}) ohne Login
- Markdown-Rendering in der geteilten Ansicht
- CSS für Share-Button, Share-Menü und Shared-Page
2026-03-04 23:34:00 +01:00

86 lines
3.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.IO;
using System.Net.Http;
using Gott.Endpoints;
using Gott.Middleware;
using Gott.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHttpClient();
var dataDir = Path.Combine(AppContext.BaseDirectory, "data");
var dbPath = Path.Combine(dataDir, "gott.db");
var authService = new AuthService(dbPath);
var dbService = new DatabaseService(dbPath);
dbService.EnsureDefaultUser(authService);
builder.Services.AddSingleton(authService);
builder.Services.AddSingleton(dbService);
builder.Services.AddSingleton(new ImageService());
builder.Services.AddSingleton(new StreamingTracker());
var memoryService = new MemoryService(dataDir);
var skillService = new SkillService(dataDir);
builder.Services.AddSingleton(memoryService);
builder.Services.AddSingleton(skillService);
// Shared Services
var toolService = new ToolService();
builder.Services.AddSingleton(toolService);
var chatService = new ChatService(dbService, toolService, memoryService, skillService);
builder.Services.AddSingleton(chatService);
// AnthropicService (Singleton – shared zwischen ChatEndpoint und TelegramService)
var anthropicToken = builder.Configuration["AnthropicToken"] ?? "";
var payloadLogging = builder.Configuration.GetValue<bool>("PayloadLogging", false);
var payloadLoggingGzip = builder.Configuration.GetValue<bool>("PayloadLoggingGzip", false);
builder.Services.AddSingleton<AnthropicService>(sp =>
new AnthropicService(
sp.GetRequiredService<IHttpClientFactory>(),
anthropicToken, toolService, dbService, memoryService,
payloadLogging, payloadLoggingGzip));
// Telegram Bot (pro Session – Token aus Session-Config)
var maxIterations = builder.Configuration.GetValue<int>("MaxIterations", 100);
builder.Services.AddSingleton<TelegramService>(sp =>
new TelegramService(
sp.GetRequiredService<IHttpClientFactory>(),
dbService, chatService,
sp.GetRequiredService<AnthropicService>(),
maxIterations));
// Krea Image Generation
var kreaToken = builder.Configuration["KreaToken"] ?? "";
builder.Services.AddSingleton(sp =>
new KreaService(sp.GetRequiredService<IHttpClientFactory>(), kreaToken, dataDir));
// Cronjob-Service (BackgroundService)
builder.Services.AddSingleton<CronjobService>();
builder.Services.AddHostedService<CronjobService>(sp => sp.GetRequiredService<CronjobService>());
var app = builder.Build();
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMiddleware<AuthMiddleware>();
app.MapAuthEndpoints();
app.MapChatEndpoint();
app.MapHistoryEndpoint();
app.MapSessionEndpoints();
app.MapAgentEndpoints();
app.MapWorkspaceEndpoint();
app.MapInfoEndpoint();
app.MapBackupEndpoint();
app.MapSkillEndpoints();
app.MapProfileEndpoints();
app.MapSettingsEndpoints();
app.MapTelegramEndpoints();
app.MapCronjobEndpoints();
app.MapKreaEndpoints();
app.MapSharedEndpoints();
app.Run("http://0.0.0.0:19000");