Telegram: Webhook-Verwaltung in Einstellungen-Seite

- Backend: DELETE /api/telegram/webhook Endpoint + TelegramService.DeleteWebhook()
- api.js: apiTelegramWebhookInfo(), apiTelegramRegisterWebhook(), apiTelegramDeleteWebhook()
- Settings-Page: Neue 'Telegram Bot' Section (nur für Admins, nur wenn konfiguriert)
  - Status abrufen: Webhook-URL, ausstehende Updates, letzter Fehler, Aktiv-Badge
  - Webhook registrieren: prompt() für Base-URL, POST an Telegram API
  - Webhook entfernen: Bestätigungsdialog + DELETE
- CSS: .telegram-status-box, .tg-status-row, .tg-label, .tg-value, .tg-badge
This commit is contained in:
Meleki committed 2026-03-03 09:06:22 +01:00
1 parent 7d237c866a
commit 4ac042e512
6 files changed
+232 -1

No files matched your search

+17
View File
@@ -27,6 +27,9 @@ public static class TelegramEndpoint
// Webhook-Info (Admin)
app.MapGet("/api/telegram/webhook-info", HandleWebhookInfo);
// Webhook löschen (Admin)
app.MapDelete("/api/telegram/webhook", HandleDeleteWebhook);
}
private static async Task HandleWebhook(HttpRequest req, HttpResponse res, TelegramService telegram)
@@ -136,4 +139,18 @@ public static class TelegramEndpoint
res.ContentType = "application/json";
await res.WriteAsync(result);
}
private static async Task HandleDeleteWebhook(HttpRequest req, HttpResponse res, TelegramService telegram)
{
if (!req.HttpContext.IsAdmin())
{
res.StatusCode = 403;
await res.WriteAsJsonAsync(new { error = "Admin required" });
return;
}
var result = await telegram.DeleteWebhook();
res.ContentType = "application/json";
await res.WriteAsync(result);
}
}