Send-test uses form auth values directly (no save required)
build-and-push / docker (push) Has been cancelled

The "send test" button now passes the currently typed token / login /
password to /api/test, falling back to saved defaults. Previously the
test only used saved settings, so testing before clicking Save sent no
auth and failed with 403 on access-controlled ntfy servers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
dimon
2026-06-02 22:04:05 +08:00
parent e696537fe1
commit f8d2c31658
3 changed files with 17 additions and 6 deletions
+8 -5
View File
@@ -526,8 +526,11 @@ async def test_notification(
server = data.server.strip() or s.default_ntfy_server
if not data.topic.strip():
raise HTTPException(400, "Укажите тему")
# Use a custom server's own auth only if it matches the default; otherwise
# fall back to the configured default-server credentials.
# Prefer auth typed in the form right now; fall back to saved defaults so
# the test works whether or not settings were saved first.
token = s.default_ntfy_token if data.token is None else data.token.strip()
username = s.default_ntfy_username if data.username is None else data.username.strip()
password = s.default_ntfy_password if data.password is None else data.password
try:
await ntfy.publish(
server=server,
@@ -536,9 +539,9 @@ async def test_notification(
message="Тестовое уведомление — всё работает!",
tags="white_check_mark",
priority=3,
token=s.default_ntfy_token,
username=s.default_ntfy_username,
password=s.default_ntfy_password,
token=token,
username=username,
password=password,
)
except Exception as exc: # noqa: BLE001
raise HTTPException(502, f"Не удалось отправить: {exc}")