Notification routing rules, per-browser push wishes, escalation of unacknowledged alerts
- Routing: rules pick channels by kind, severity and server tags (first match wins, none = nobody); mixed batches split per route; recoveries follow their alert; quiet-hours digest keeps each notification's audience - Push: each subscribed browser can ask for a minimum severity and some kinds - Escalation: up to three timed steps re-notify alerts nobody has acknowledged, through chosen channels and an optional extra email; an acknowledgement stops them - Fix ntfy: titles with an em dash made every ntfy send fail (header not Latin-1); now RFC 2047 encoded Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9caa414829
commit
43fc5e0272
21 files changed
+4769
-55
No files matched your search
@@ -8,6 +8,8 @@ import {
|
||||
type SmtpSettings,
|
||||
type WebhookSettings,
|
||||
type WebPushSettings,
|
||||
type RoutingSettings,
|
||||
type EscalationSettings,
|
||||
type NotificationEvents,
|
||||
type DigestSettings,
|
||||
type QuietHoursSettings,
|
||||
@@ -17,6 +19,7 @@ import { readableError } from "../../utils/errors";
|
||||
import { ErrorNotice } from "../../components/Notice";
|
||||
import { PageSkeleton } from "../../components/Skeleton";
|
||||
import PushDevices from "../../components/PushDevices";
|
||||
import RoutingEditor from "../../components/RoutingEditor";
|
||||
|
||||
const TIMEZONES = [
|
||||
"UTC",
|
||||
@@ -46,6 +49,8 @@ const DEFAULT_NTFY: NtfySettings = { enabled: false, url: "https://ntfy.sh", top
|
||||
const DEFAULT_SMTP: SmtpSettings = { enabled: false, host: "", port: 587, secure: false, username: "", password: "", from: "", to: "" };
|
||||
const DEFAULT_WEBHOOK: WebhookSettings = { enabled: false, url: "", secret: "" };
|
||||
const DEFAULT_WEBPUSH: WebPushSettings = { enabled: false, contact: "" };
|
||||
const DEFAULT_ROUTING: RoutingSettings = { rules: [] };
|
||||
const DEFAULT_ESCALATION: EscalationSettings = { enabled: false, steps: [] };
|
||||
const DEFAULT_NOTIFICATIONS: NotificationEvents = {
|
||||
dnsAdd: true,
|
||||
dnsUpdate: true,
|
||||
@@ -84,6 +89,7 @@ type EventKey = { [K in keyof NotificationEvents]: NotificationEvents[K] extends
|
||||
const TABS = [
|
||||
{ id: "channels", label: "Channels" },
|
||||
{ id: "events", label: "What to send" },
|
||||
{ id: "routing", label: "Who hears what" },
|
||||
{ id: "when", label: "When" },
|
||||
] as const;
|
||||
type TabId = (typeof TABS)[number]["id"];
|
||||
@@ -225,6 +231,8 @@ export default function NotificationSettings() {
|
||||
const [webPush, setWebPush] = useState<WebPushSettings>(DEFAULT_WEBPUSH);
|
||||
// Whether push is on as saved: people can only add their browsers once the server knows it is on.
|
||||
const [webPushSaved, setWebPushSaved] = useState(false);
|
||||
const [routing, setRouting] = useState<RoutingSettings>(DEFAULT_ROUTING);
|
||||
const [escalation, setEscalation] = useState<EscalationSettings>(DEFAULT_ESCALATION);
|
||||
const [notifications, setNotifications] = useState<NotificationEvents>(DEFAULT_NOTIFICATIONS);
|
||||
const [quietHours, setQuietHours] = useState<QuietHoursSettings>(DEFAULT_QUIET_HOURS);
|
||||
const [healthChecks, setHealthChecks] = useState<HealthCheckSettings>(DEFAULT_HEALTH_CHECKS);
|
||||
@@ -245,7 +253,7 @@ export default function NotificationSettings() {
|
||||
const [testingWebhook, setTestingWebhook] = useState(false);
|
||||
const [testWebhookResult, setTestWebhookResult] = useState<TestResult>(null);
|
||||
|
||||
const snapshot = JSON.stringify({ gotify, ntfy, smtp, webhook, webPush, notifications, quietHours, healthChecks, digest });
|
||||
const snapshot = JSON.stringify({ gotify, ntfy, smtp, webhook, webPush, routing, escalation, notifications, quietHours, healthChecks, digest });
|
||||
const dirty = baseline !== null && snapshot !== baseline;
|
||||
|
||||
useEffect(() => {
|
||||
@@ -260,12 +268,16 @@ export default function NotificationSettings() {
|
||||
const wp = s.webPush ?? DEFAULT_WEBPUSH;
|
||||
setWebPush(wp);
|
||||
setWebPushSaved(wp.enabled);
|
||||
const rt = s.routing ?? DEFAULT_ROUTING;
|
||||
const es = s.escalation ?? DEFAULT_ESCALATION;
|
||||
setRouting(rt);
|
||||
setEscalation(es);
|
||||
setNotifications(s.notifications);
|
||||
setQuietHours(s.quietHours);
|
||||
setHealthChecks(s.healthChecks);
|
||||
const d = s.digest ?? DEFAULT_DIGEST;
|
||||
setDigest(d);
|
||||
setBaseline(JSON.stringify({ gotify: s.gotify, ntfy: s.ntfy, smtp: s.smtp, webhook: s.webhook, webPush: wp, notifications: s.notifications, quietHours: s.quietHours, healthChecks: s.healthChecks, digest: d }));
|
||||
setBaseline(JSON.stringify({ gotify: s.gotify, ntfy: s.ntfy, smtp: s.smtp, webhook: s.webhook, webPush: wp, routing: rt, escalation: es, notifications: s.notifications, quietHours: s.quietHours, healthChecks: s.healthChecks, digest: d }));
|
||||
})
|
||||
.catch((err) => setLoadError(err instanceof Error ? err.message : String(err)))
|
||||
.finally(() => setLoading(false));
|
||||
@@ -312,7 +324,7 @@ export default function NotificationSettings() {
|
||||
setSaveError(null);
|
||||
setSaved(false);
|
||||
try {
|
||||
await api.settings.update({ gotify, ntfy, smtp, webhook, webPush, notifications, quietHours, healthChecks, digest });
|
||||
await api.settings.update({ gotify, ntfy, smtp, webhook, webPush, routing, escalation, notifications, quietHours, healthChecks, digest });
|
||||
setBaseline(snapshot);
|
||||
setWebPushSaved(webPush.enabled);
|
||||
setSaved(true);
|
||||
@@ -777,6 +789,17 @@ export default function NotificationSettings() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ── Who hears what ── */}
|
||||
<div role="tabpanel" id="panel-routing" aria-labelledby="tab-routing" hidden={tab !== "routing"} className="pt-3">
|
||||
<RoutingEditor
|
||||
routing={routing}
|
||||
onRouting={setRouting}
|
||||
escalation={escalation}
|
||||
onEscalation={setEscalation}
|
||||
channelsOn={{ gotify: gotify.enabled && gotifyComplete, ntfy: ntfy.enabled && ntfyComplete, smtp: smtp.enabled && smtpComplete, webhook: webhook.enabled && webhookComplete, webPush: webPush.enabled }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* ── When ── */}
|
||||
<div role="tabpanel" id="panel-when" aria-labelledby="tab-when" hidden={tab !== "when"} className="pt-3">
|
||||
<p className="text-secondary">When notifications are sent: the time zone everything here runs in, the daily reminders, hours to keep quiet, and the weekly digest.</p>
|
||||
|
||||
Reference in new issue
Block a user