Documentation
¶
Overview ¶
Package notify delivers platform-native desktop notifications — Windows toast popups, macOS Notification Center panels, Linux D-Bus notifications — behind a small level vocabulary (info / warning / error / attention).
It is the delivery half of the remote-notify feature: the web API's POST /api/v1/remote/notify handler and the `dotvault notify` CLI both build a Message and hand it to a Notifier, so a headless peer can surface a notification on the workstation over the same forwarded socket that carries the token borrow and remote browse.
Delivery is via github.com/gen2brain/beeep, which is pure Go (no cgo) with build-tagged platform backends, preserving the repo's CGO_ENABLED=0 invariant. The package exposes an injectable Notifier seam (Send is the default) so callers can fake delivery in tests without popping real notifications.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Levels ¶
func Levels() []string
Levels returns the accepted level names in canonical order, for CLI help and error messages.
func Send ¶
Send delivers msg via the platform's native notification mechanism. It is the default Notifier. A level's urgency selects an audible alert (error / attention) or a normal notification (info / warning), and on platforms that accept a named stock icon the level's icon is shown. When msg carries an ActionURL, delivery is platform-specific (see platformDeliver): a clickable toast on Windows, the URL appended to the body elsewhere.
Types ¶
type Level ¶
type Level string
Level classifies a notification's severity. It drives two things: the urgency of delivery (error and attention are delivered as audible, higher-priority alerts) and, where the platform supports a named stock icon (Linux/BSD via D-Bus), the icon shown.
func ParseLevel ¶
ParseLevel validates a level name (case-insensitive) and returns the canonical Level. An unknown name is an error naming the accepted set.
type Message ¶
type Message struct {
Level Level
Title string
Body string
// ActionURL, when non-empty, is an http/https URL the notification should
// take the user to when clicked. It is validated by NewMessage. Whether it
// is actually *clickable* is platform-dependent: on Windows the toast is
// activated to open the URL; on macOS/Linux, where a one-shot delivery
// cannot register a click handler, the URL is appended to the body so it
// stays visible and copyable (see actionBody / platformDeliver).
ActionURL string
}
Message is a validated notification ready for delivery.
func NewMessage ¶
NewMessage validates and sanitizes the inputs into a Message. The level must be a known level; the title must be non-empty after sanitization; the body is optional. Title and body are sanitized (control characters removed, delivery-backend metacharacters neutralized — see sanitize) and capped in length. actionURL is optional; when set it must be an http/https URL with a host and no embedded credentials.