notify

package
v1.13.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 21 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 notify sends a periodic e-mail digest of open tasks over SMTP. It is deliberately small: STARTTLS submission (port 587) via the standard library, a plain-text and an HTML body built from the metadata index, and a background ticker. Disabled unless VELLUM_NOTIFY=on and SMTP settings are present.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled   bool
	Host      string
	Port      string
	User      string
	Pass      string
	From      string
	To        []string
	Interval  time.Duration
	PublicURL string
}

Config holds SMTP settings and the digest cadence.

func FromEnv

func FromEnv(publicURL string) Config

FromEnv reads the SMTP configuration from the environment.

func (Config) Valid

func (c Config) Valid() bool

Valid reports whether enough is set to actually send mail.

type Mailer

type Mailer interface {
	Send(m Message) error
}

Mailer sends one message. Abstracted so the digest logic is testable.

type Message added in v1.13.0

type Message struct {
	Subject string
	Text    string
	HTML    string
	Open    int // open tasks (in progress + backlog)
}

Message is one rendered digest: a plain-text and an HTML body of the same content.

func Digest

func Digest(ix Tasks, publicURL string, now time.Time, window time.Duration) Message

Digest builds the digest of open tasks, plus the tasks marked done within the last window (normally the digest interval). Tasks are listed most recently updated first.

type Notifier

type Notifier struct {
	// contains filtered or unexported fields
}

Notifier runs the periodic digest.

func New

func New(cfg Config, tasks Tasks, log *slog.Logger) *Notifier

New builds a Notifier that mails via SMTP using cfg.

func (*Notifier) Loop

func (n *Notifier) Loop(ctx context.Context)

Loop sends a digest shortly after boot (to confirm the setup) and then every cfg.Interval until ctx is cancelled.

func (*Notifier) SendDigest

func (n *Notifier) SendDigest()

SendDigest builds and sends one digest now. Tasks done within the last interval are listed as well.

type Tasks

type Tasks interface {
	ListTasks(status, project string) []vault.Entry
}

Tasks is the slice of the index the digest needs.

Jump to

Keyboard shortcuts

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