import { useEffect, useState } from "react"; import { api } from "../../api/client"; import { readableError } from "../../utils/errors"; import { toast } from "../../utils/toast"; /** * Buttons on notifications: Acknowledge, Silence for an hour and Snooze until tomorrow, pressed from the message itself without signing in. Its own switch, saved at once (it is not * part of the page's Save, since it is not a notification setting so much as a way of acting on one). */ export default function AlertActionsCard() { const [enabled, setEnabled] = useState(null); const [busy, setBusy] = useState(false); useEffect(() => { let alive = true; api.settings .get() .then((res) => alive && setEnabled(res.settings.alertActions?.enabled ?? false)) .catch(() => alive && setEnabled(false)); return () => { alive = false; }; }, []); async function change(value: boolean) { setBusy(true); try { await api.settings.update({ alertActions: { enabled: value } }); setEnabled(value); toast.success(value ? "Notifications now carry buttons." : "Buttons on notifications are switched off; their links stop working."); } catch (err) { toast.error(readableError(err)); } finally { setBusy(false); } } return (

Buttons on notifications

Let a notification itself carry Acknowledge, Silence for an hour and Snooze until tomorrow — as buttons on an ntfy message or a phone push, and as a link in an email, a Gotify message or the chat webhook — so a problem can be dealt with from the lock screen, without opening the app or signing in.

  • Each link is for the alerts in that one message and can do only those three things. It cannot read anything, change a setting or reach any other part of the app, and it stops working after 24 hours.
  • Anyone who can read the notification can press its buttons while it lasts. That is fine for a private ntfy topic, a Gotify server of your own, your own phone or your own inbox; it is not for a public ntfy.sh topic or a chat channel with guests in it.
  • Opening a link never does anything — a link preview or a mail scanner is harmless; only pressing a button acts. Everything it does is in the audit log as from a notification link, with where it came from.
  • Messages about one alert get buttons (ntfy: three; a phone push: two); messages about several get one link to a page that lists them. A message held for quiet hours is sent without them. Changing the SESSION_SECRET ends every link at once; switching this off does too.
  • The links are built from the address people reach this app at (APP_BASE_URL); it has to be one your phone can open.
); }