notify

package
v0.4.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package notify is FlatRun's core notification service. It stores delivery targets (email, webhook, chat, ... as shoutrrr URLs), routes events to the enabled ones, and can send a test message. It is a core capability: plugins emit events and the core delivers them, so notification configuration lives in one place rather than per plugin.

Index

Constants

View Source
const MaskedURL = "********"

MaskedURL stands in for a target URL in API responses. A shoutrrr URL carries its credentials inline (an SMTP password, a webhook token), so the real URL is never returned to a client; it is written verbatim only to the on-disk store.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Targets []Target `yaml:"targets" json:"targets"`
}

Config is the persisted notification settings.

type Service

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

Service loads/saves targets and delivers messages.

func NewService

func NewService(basePath string) *Service

func (*Service) Load

func (s *Service) Load() Config

func (*Service) Notify

func (s *Service) Notify(title, message string) error

Notify delivers title + message to every enabled target. It returns the first delivery error, if any, but attempts all targets.

func (*Service) NotifyTargets

func (s *Service) NotifyTargets(title, message string, ids []string) error

NotifyTargets delivers to a chosen subset of targets by id. An empty list means every enabled target, which is what plain Notify does.

func (*Service) Save

func (s *Service) Save(cfg Config) error

func (*Service) Test

func (s *Service) Test(url string) error

Test sends a message to a single URL, so an admin can verify a target before saving it.

func (*Service) Update

func (s *Service) Update(cfg Config) error

Update saves targets, restoring the stored URL for any target whose incoming URL is the mask: a client that received a masked target and saved it back unchanged must not overwrite the real URL with the mask.

type Target

type Target struct {
	ID      string `yaml:"id" json:"id"`
	Name    string `yaml:"name" json:"name"`
	URL     string `yaml:"url" json:"url"`
	Enabled bool   `yaml:"enabled" json:"enabled"`
}

Target is one delivery destination. URL is a shoutrrr service URL, e.g. "smtp://user:pass@host:587/?from=x&to=y" or "generic+https://example.com/hook".

func (Target) MarshalJSON

func (t Target) MarshalJSON() ([]byte, error)

MarshalJSON masks the credential-bearing URL. YAML persistence does not use this path, so the stored file keeps the real URL.

Jump to

Keyboard shortcuts

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