mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-19 08:12:52 +00:00
fix(notifications): answer a failed channel test with its cause
The webhook, ntfy and email test routes turned every delivery failure into a bare 500, so the settings card could only say "Test failed" while the server knew the relay had answered 400. A failure at the other end, or on the way to it, is now a 502 with meta.errorCode, the upstream HTTP status or SMTP reply code, and for webhook and ntfy what the relay answered when that is short and holds no credential. The codes reuse the test card's vocabulary; upstream_rejected is new, for a relay that accepted the connection and refused the payload. The private-origin 422 is unchanged, and only a failure the server cannot name stays a 500. The guard that pinned the bare 500 now asserts the opposite, with the reason in its name. The admin fan-out test reports the same code and status per channel, and tests the webhook and email channels, which it used to list as an unknown channel type. Refs #947
This commit is contained in:
1 parent
8c345f600e
commit
f6a890df8a
11 files changed
+744
-39
No files matched your search
@@ -7,6 +7,7 @@ import { checkRateLimit } from "@/lib/rate-limit";
|
||||
import { apiHandler, requireAuth } from "@/lib/api-handler";
|
||||
import { annotate } from "@/lib/logging/context";
|
||||
import { isEmailConfigured } from "@/lib/notifications/senders/email-config";
|
||||
import { answerTestDeliveryFailure } from "@/lib/notifications/test-delivery-failure";
|
||||
|
||||
/**
|
||||
* POST: send a test email to the configured recipient.
|
||||
@@ -46,7 +47,13 @@ export const POST = apiHandler(async () => {
|
||||
});
|
||||
|
||||
if (!result.ok) {
|
||||
return apiError("Failed to send test email", 500);
|
||||
// The mail server, or the way to it, failed: 502 with the code and the
|
||||
// SMTP reply code. Only an unnamed internal fault is a 500.
|
||||
return answerTestDeliveryFailure(result, {
|
||||
channel: "email",
|
||||
label: "The mail server",
|
||||
fallbackMessage: "Failed to send test email",
|
||||
});
|
||||
}
|
||||
|
||||
annotate({
|
||||
|
||||
Reference in new issue
Block a user