feat(notifications): add Telegram test button

New "Test senden" button next to Speichern posts current form
credentials (not DB) to /actions/notifications/test, which fires a
test message and redirects back with a flash chip showing the outcome
(including the Telegram API's error description on failure).

telegram_send is now public and returns (ok, detail) so the UI can
surface real error messages ("chat not found", "Unauthorized", etc.).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
EiSiMo 2026-04-23 09:35:02 +02:00
parent d06dfdaca1
commit 64439fd42e
3 changed files with 63 additions and 8 deletions

View file

@ -3,6 +3,18 @@
Wähle einen Kanal und entscheide, welche Events dich erreichen sollen.
</p>
{% if notif_flash %}
<div class="chip mb-4
{% if notif_flash == 'test_ok' %}chip-ok
{% else %}chip-bad
{% endif %}">
{% if notif_flash == 'test_ok' %}Testnachricht gesendet.
{% elif notif_flash == 'test_missing' %}Bot-Token und Chat-ID eintragen, um zu testen.
{% elif notif_flash == 'test_fail' %}Test fehlgeschlagen{% if notif_flash_detail %}: {{ notif_flash_detail }}{% endif %}.
{% endif %}
</div>
{% endif %}
<form method="post" action="/actions/notifications" class="space-y-4 max-w-xl"
autocomplete="off" data-lpignore="true" data-1p-ignore data-bwignore data-form-type="other">
<input type="hidden" name="csrf" value="{{ csrf }}">
@ -42,5 +54,9 @@
</label>
</div>
<button class="btn btn-primary" type="submit">Speichern</button>
<div class="flex gap-2">
<button class="btn btn-primary" type="submit">Speichern</button>
<button class="btn btn-ghost" type="submit"
formaction="/actions/notifications/test" formnovalidate>Test senden</button>
</div>
</form>