sinks

package
v2.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sinks fans notifications out to web-push, a Discord webhook and ntfy, best-effort and never blocking the caller.

ntfy approval notifications carry real approve/deny HTTP action buttons, so a phone can decide without opening the app (and without VAPID setup).

Index

Constants

This section is empty.

Variables

View Source
var Keys = []string{"discord_webhook", "ntfy_server", "ntfy_topic"}

Keys are the settings rows this package owns. Anything else is rejected by the settings endpoint so a typo cannot silently disable notifications.

Functions

func Subscribe

func Subscribe(db *store.DB, sub push.Subscription) error

Subscribe records (or refreshes) a browser push subscription.

Types

type Extra

type Extra struct {
	Kind       string
	ApprovalID int64
}

Extra carries the notification's context — which is what turns an ntfy message into one with decision buttons.

type Notifier

type Notifier struct {
	DB      *store.DB
	BaseURL string
	Push    *push.Sender
	Log     *slog.Logger
	Client  *http.Client

	// Hook, when set, replaces real delivery. Tests assert on the built payloads
	// without any network at all — the same seam the Python suite used.
	Hook func([]Payload)
	// contains filtered or unexported fields
}

Notifier owns the sink fan-out.

func (*Notifier) Notify

func (n *Notifier) Notify(title, body, urlPath string, extra *Extra)

Notify sends to every configured sink. Delivery happens on a goroutine: a sink outage must never slow a dispatch down, let alone fail one.

func (*Notifier) Settings

func (n *Notifier) Settings() map[string]string

Settings reads the configured sinks.

func (*Notifier) Wait

func (n *Notifier) Wait()

Wait blocks until in-flight deliveries finish — used at shutdown.

type Payload

type Payload struct {
	Kind string         `json:"kind"`
	URL  string         `json:"url"`
	Body map[string]any `json:"body"`
}

Payload is one outbound notification, already addressed and rendered.

func BuildPayloads

func BuildPayloads(cfg map[string]string, baseURL, title, body, urlPath string, extra *Extra) []Payload

BuildPayloads is the pure builder: one payload per configured sink.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL