notify

package
v0.98.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package notify provides the notification dispatcher interface and registry.

Index

Constants

View Source
const (
	// AgentNotifyTemplateID is the seeded template for chatagent send_notification.
	AgentNotifyTemplateID = "agent.notify"
	// AgentNotifyTemplateBody is the default body for AgentNotifyTemplateID.
	AgentNotifyTemplateBody = "{{ .summary }}"
)
View Source
const (
	RuleActionThrottle  = manifest.RuleActionThrottle
	RuleActionAggregate = manifest.RuleActionAggregate
	RuleActionMute      = manifest.RuleActionMute
	RuleActionDrop      = manifest.RuleActionDrop
)

Rule action constants.

View Source
const ConnectivityTestTemplateID = "test"

ConnectivityTestTemplateID is the template ID written by web UI channel connectivity tests. Retry for these records re-runs the channel probe instead of GatewaySend.

View Source
const (
	// PayloadKeySummary is the key in the GatewaySend payload map for the summary text.
	PayloadKeySummary = "summary"
)
View Source
const PlaygroundTemplateID = "playground"

PlaygroundTemplateID is the template ID written by the Notifications playground when sending with a custom (ad-hoc) template body.

Variables

View Source
var (
	// ErrNoDefaultChannel reports that no enabled default notify channel is configured.
	ErrNoDefaultChannel = errors.New("no default notify channel configured")
	// ErrNoDefaultTemplate reports that no default notify template is configured.
	ErrNoDefaultTemplate = errors.New("no default notify template configured")
)

Functions

func GatewaySend added in v0.92.0

func GatewaySend(ctx context.Context, uid types.Uid, templateID string, channels []string, payload map[string]any) error

GatewaySend is the central notification gateway entry point. It renders a notification template and dispatches the message to the specified channels. Channels are resolved from the global NotifyChannel registry first; when a UID is set, per-user notify:<channel> config is used as a fallback. Rules (throttle, mute, aggregate) are applied before sending (when rule engine is initialized).

func GatewaySendDefaultChannel added in v0.98.0

func GatewaySendDefaultChannel(ctx context.Context, uid types.Uid, templateID string, payload map[string]any) error

GatewaySendDefaultChannel sends using an explicit template and the global default channel.

func GatewaySendDefaults added in v0.98.0

func GatewaySendDefaults(ctx context.Context, uid types.Uid, payload map[string]any) error

GatewaySendDefaults sends using the global default template and default channel.

func GetNotifyStore added in v0.92.0

func GetNotifyStore() *store.NotifyStore

GetNotifyStore returns the NotifyStore from the global database adapter, or nil if the store is not available.

func IsConnectivityTestTemplate added in v0.97.8

func IsConnectivityTestTemplate(templateID string) bool

IsConnectivityTestTemplate reports whether templateID identifies a connectivity-test record.

func IsPlaygroundTemplate added in v0.97.8

func IsPlaygroundTemplate(templateID string) bool

IsPlaygroundTemplate reports whether templateID identifies a playground custom-send record.

func List

func List() map[string]Notifyer

List returns a copy of the registered Notifyer map.

func ParseSchema

func ParseSchema(testString string) (string, error)

func ParseTemplate

func ParseTemplate(testString string, templates []string) (types.KV, error)

func Register

func Register(id string, notifyer Notifyer)

Register adds a Notifyer to the global registry.

func ResolveDefaultChannelName added in v0.98.0

func ResolveDefaultChannelName(ctx context.Context) (string, error)

ResolveDefaultChannelName returns the name of the global default enabled channel.

func ResolveDefaultTemplateID added in v0.98.0

func ResolveDefaultTemplateID(ctx context.Context) (string, error)

ResolveDefaultTemplateID returns the template_id of the global default template.

func SeedAgentNotifyTemplate added in v0.98.0

func SeedAgentNotifyTemplate(ctx context.Context) error

SeedAgentNotifyTemplate ensures the agent.notify template exists (not marked default).

func Send

func Send(text string, message Message) error

func SendToProtocol added in v0.97.8

func SendToProtocol(protocol, uri string, message Message) error

SendToProtocol dispatches a message using an explicit notify protocol. Unlike Send, the URI scheme (for example http/https used by ntfy endpoints) is not used for provider lookup — protocol selects the Notifyer.

func TemplateReferencesSummary added in v0.98.0

func TemplateReferencesSummary(defaultTemplate, overridesJSON string) bool

TemplateReferencesSummary reports whether a template body (and overrides JSON) references the summary payload field used by GatewaySendDefaults.

func Unregister added in v0.97.8

func Unregister(id string)

Unregister removes a previously registered Notifyer. It is a no-op if the id is not found. Intended primarily for test teardown.

func UserNotifyChannels added in v0.97.8

func UserNotifyChannels(ctx context.Context, uid types.Uid) ([]string, error)

UserNotifyChannels returns channel names configured for the user under notify:<channel> keys.

func WaitForRecordAsyncForTest added in v0.97.8

func WaitForRecordAsyncForTest()

WaitForRecordAsyncForTest blocks until all in-flight recordAsync goroutines finish.

func WarnSkipNoDefault added in v0.98.0

func WarnSkipNoDefault(err error, what string) bool

WarnSkipNoDefault logs and skips when err is a missing-default sentinel. Returns true when the caller should treat the send as a soft skip.

Types

type Message

type Message struct {
	Title    string
	Body     string
	Url      string
	Priority Priority
}

type Notifyer

type Notifyer interface {
	// Protocol Define protocol
	Protocol() string
	// Templates Define object templates
	Templates() []string
	// Send notify
	Send(tokens types.KV, message Message) error
}

type Override added in v0.97.8

type Override = manifest.Override

Override is a channel-specific template override.

type Priority

type Priority int32
const (
	Low Priority = iota + 1
	Moderate
	Normal
	High
	Emergency
)

type Rule added in v0.97.8

type Rule = manifest.Rule

Rule is a notification filtering or aggregation rule.

type RuleAction added in v0.97.8

type RuleAction = manifest.RuleAction

RuleAction is the action to take when a rule matches.

type RuleMatch added in v0.97.8

type RuleMatch = manifest.RuleMatch

RuleMatch is the event and channel matching criteria.

type RuleParams added in v0.97.8

type RuleParams = manifest.RuleParams

RuleParams holds action-specific parameters.

type Template added in v0.97.8

type Template = manifest.Template

Template is a notification message template with optional per-channel overrides.

Directories

Path Synopsis
Package manifest holds shared notification template and rule type definitions.
Package manifest holds shared notification template and rule type definitions.
Package messagepusher implements the Message Pusher notification provider.
Package messagepusher implements the Message Pusher notification provider.
Package ntfy implements the ntfy notification provider.
Package ntfy implements the ntfy notification provider.
Package pushover implements Pushover notification provider.
Package pushover implements Pushover notification provider.
Package rules provides the notification rule engine for throttling, aggregation, and mute/DND.
Package rules provides the notification rule engine for throttling, aggregation, and mute/DND.
Package slack implements the Slack notification provider.
Package slack implements the Slack notification provider.
Package template provides notification template rendering using Go text/template with Sprig function library support.
Package template provides notification template rendering using Go text/template with Sprig function library support.

Jump to

Keyboard shortcuts

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