notification

package
v2.11.3 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSettingsNotFound   = errors.New("notification settings not found")
	ErrInvalidSettings    = errors.New("invalid notification settings")
	ErrChannelNotFound    = errors.New("notification channel not found")
	ErrChannelInUse       = errors.New("notification channel is in use")
	ErrRouteSetNotFound   = errors.New("notification route set not found")
	ErrTargetNotFound     = errors.New("notification target not found")
	ErrUnsupportedEvent   = errors.New("unsupported notification event")
	ErrUnsupportedTarget  = errors.New("unsupported notification target provider")
	ErrSecretStoreMissing = errors.New("notification secret store is not configured")
)

Functions

func IsEventEnabled

func IsEventEnabled(settings *Settings, event eventstore.EventType) bool

func IsRouteEventEnabled

func IsRouteEventEnabled(routeSet *RouteSet, route Route, event eventstore.EventType) bool

func IsSlackIncomingWebhookURL

func IsSlackIncomingWebhookURL(value string) bool

func IsSubscriptionEventEnabled

func IsSubscriptionEventEnabled(settings *Settings, subscription Subscription, event eventstore.EventType) bool

func IsTargetEventEnabled

func IsTargetEventEnabled(settings *Settings, target Target, event eventstore.EventType) bool

func PreserveChannelSecrets

func PreserveChannelSecrets(next, existing *Channel)

func PreserveSecrets

func PreserveSecrets(next, existing *Settings)

func PreserveWorkspaceSecrets

func PreserveWorkspaceSecrets(next, existing *WorkspaceSettings)

func PreviewSecret

func PreviewSecret(value string) string

Types

type Channel

type Channel struct {
	ID      string       `json:"id"`
	Name    string       `json:"name"`
	Type    ProviderType `json:"type"`
	Enabled bool         `json:"enabled"`

	Email    *EmailTarget    `json:"email,omitempty"`
	Webhook  *WebhookTarget  `json:"webhook,omitempty"`
	Slack    *SlackTarget    `json:"slack,omitempty"`
	Telegram *TelegramTarget `json:"telegram,omitempty"`

	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	UpdatedBy string    `json:"updatedBy,omitempty"`
}

func NormalizeChannel

func NormalizeChannel(channel *Channel, updatedBy string) (*Channel, error)

func (Channel) ToPublic

func (c Channel) ToPublic() PublicChannel

func (Channel) ToTarget

func (c Channel) ToTarget() Target

type EmailTarget

type EmailTarget struct {
	From            string   `json:"from,omitempty"`
	To              []string `json:"to,omitempty"`
	Cc              []string `json:"cc,omitempty"`
	Bcc             []string `json:"bcc,omitempty"`
	SubjectPrefix   string   `json:"subjectPrefix,omitempty"`
	SubjectTemplate string   `json:"subjectTemplate,omitempty"`
	BodyTemplate    string   `json:"bodyTemplate,omitempty"`
	AttachLogs      bool     `json:"attachLogs,omitempty"`
}

type ProviderType

type ProviderType string
const (
	ProviderEmail    ProviderType = "email"
	ProviderWebhook  ProviderType = "webhook"
	ProviderSlack    ProviderType = "slack"
	ProviderTelegram ProviderType = "telegram"
)

type PublicChannel

type PublicChannel struct {
	ID      string       `json:"id"`
	Name    string       `json:"name"`
	Type    ProviderType `json:"type"`
	Enabled bool         `json:"enabled"`

	Email    *EmailTarget          `json:"email,omitempty"`
	Webhook  *PublicWebhookTarget  `json:"webhook,omitempty"`
	Slack    *PublicSlackTarget    `json:"slack,omitempty"`
	Telegram *PublicTelegramTarget `json:"telegram,omitempty"`

	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	UpdatedBy string    `json:"updatedBy,omitempty"`
}

type PublicRoute

type PublicRoute struct {
	ID        string   `json:"id"`
	ChannelID string   `json:"channelId"`
	Enabled   bool     `json:"enabled"`
	Events    []string `json:"events,omitempty"`
}

type PublicRouteSet

type PublicRouteSet struct {
	ID            string        `json:"id"`
	Scope         RouteScope    `json:"scope"`
	Workspace     string        `json:"workspace,omitempty"`
	Enabled       bool          `json:"enabled"`
	InheritGlobal bool          `json:"inheritGlobal"`
	Routes        []PublicRoute `json:"routes"`
	CreatedAt     time.Time     `json:"createdAt"`
	UpdatedAt     time.Time     `json:"updatedAt"`
	UpdatedBy     string        `json:"updatedBy,omitempty"`
}

type PublicSMTPConfig

type PublicSMTPConfig struct {
	Host               string `json:"host,omitempty"`
	Port               string `json:"port,omitempty"`
	Username           string `json:"username,omitempty"`
	From               string `json:"from,omitempty"`
	PasswordConfigured bool   `json:"passwordConfigured"`
}

type PublicSettings

type PublicSettings struct {
	ID            string               `json:"id"`
	DAGName       string               `json:"dagName"`
	Enabled       bool                 `json:"enabled"`
	Events        []string             `json:"events"`
	Targets       []PublicTarget       `json:"targets"`
	Subscriptions []PublicSubscription `json:"subscriptions,omitempty"`
	CreatedAt     time.Time            `json:"createdAt"`
	UpdatedAt     time.Time            `json:"updatedAt"`
	UpdatedBy     string               `json:"updatedBy,omitempty"`
}

func ToPublic

func ToPublic(settings *Settings) *PublicSettings

type PublicSlackTarget

type PublicSlackTarget struct {
	WebhookURLConfigured bool   `json:"webhookUrlConfigured"`
	WebhookURLPreview    string `json:"webhookUrlPreview,omitempty"`
	MessageTemplate      string `json:"messageTemplate,omitempty"`
}

type PublicSubscription

type PublicSubscription struct {
	ID        string   `json:"id"`
	ChannelID string   `json:"channelId"`
	Enabled   bool     `json:"enabled"`
	Events    []string `json:"events,omitempty"`
}

type PublicTarget

type PublicTarget struct {
	ID      string       `json:"id"`
	Name    string       `json:"name,omitempty"`
	Type    ProviderType `json:"type"`
	Enabled bool         `json:"enabled"`
	Events  []string     `json:"events,omitempty"`

	Email    *EmailTarget          `json:"email,omitempty"`
	Webhook  *PublicWebhookTarget  `json:"webhook,omitempty"`
	Slack    *PublicSlackTarget    `json:"slack,omitempty"`
	Telegram *PublicTelegramTarget `json:"telegram,omitempty"`
}

type PublicTelegramTarget

type PublicTelegramTarget struct {
	BotTokenConfigured bool   `json:"botTokenConfigured"`
	BotTokenPreview    string `json:"botTokenPreview,omitempty"`
	ChatID             string `json:"chatId,omitempty"`
	TopicID            string `json:"topicId,omitempty"`
	MessageTemplate    string `json:"messageTemplate,omitempty"`
}

type PublicWebhookTarget

type PublicWebhookTarget struct {
	URLConfigured        bool              `json:"urlConfigured"`
	URLPreview           string            `json:"urlPreview,omitempty"`
	Headers              map[string]string `json:"headers,omitempty"`
	HMACSecretConfigured bool              `json:"hmacSecretConfigured"`
	MessageTemplate      string            `json:"messageTemplate,omitempty"`
	AllowInsecureHTTP    bool              `json:"allowInsecureHttp"`
	AllowPrivateNetwork  bool              `json:"allowPrivateNetwork"`
}

type PublicWorkspaceSettings

type PublicWorkspaceSettings struct {
	SMTP *PublicSMTPConfig `json:"smtp,omitempty"`

	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	UpdatedBy string    `json:"updatedBy,omitempty"`
}

type Route

type Route struct {
	ID        string                 `json:"id"`
	ChannelID string                 `json:"channelId"`
	Enabled   bool                   `json:"enabled"`
	Events    []eventstore.EventType `json:"events,omitempty"`
}

func (Route) ToPublic

func (r Route) ToPublic() PublicRoute

type RouteScope

type RouteScope string
const (
	RouteScopeGlobal    RouteScope = "global"
	RouteScopeWorkspace RouteScope = "workspace"
)

type RouteSet

type RouteSet struct {
	ID            string     `json:"id"`
	Scope         RouteScope `json:"scope"`
	Workspace     string     `json:"workspace,omitempty"`
	Enabled       bool       `json:"enabled"`
	InheritGlobal bool       `json:"inheritGlobal"`
	Routes        []Route    `json:"routes"`
	CreatedAt     time.Time  `json:"createdAt"`
	UpdatedAt     time.Time  `json:"updatedAt"`
	UpdatedBy     string     `json:"updatedBy,omitempty"`
}

func NormalizeRouteSet

func NormalizeRouteSet(routeSet *RouteSet, updatedBy string) (*RouteSet, error)

func (RouteSet) ToPublic

func (s RouteSet) ToPublic() PublicRouteSet

type SMTPConfig

type SMTPConfig struct {
	Host          string `json:"host,omitempty"`
	Port          string `json:"port,omitempty"`
	Username      string `json:"username,omitempty"`
	Password      string `json:"password,omitempty"`
	From          string `json:"from,omitempty"`
	ClearPassword bool   `json:"-"`
}

type Settings

type Settings struct {
	ID            string                 `json:"id"`
	DAGName       string                 `json:"dagName"`
	Enabled       bool                   `json:"enabled"`
	Events        []eventstore.EventType `json:"events"`
	Targets       []Target               `json:"targets"`
	Subscriptions []Subscription         `json:"subscriptions,omitempty"`
	CreatedAt     time.Time              `json:"createdAt"`
	UpdatedAt     time.Time              `json:"updatedAt"`
	UpdatedBy     string                 `json:"updatedBy,omitempty"`
}

func NewSettings

func NewSettings(dagName, updatedBy string) (*Settings, error)

func Normalize

func Normalize(settings *Settings, updatedBy string) (*Settings, error)

type SlackTarget

type SlackTarget struct {
	WebhookURL      string `json:"webhookUrl,omitempty"`
	MessageTemplate string `json:"messageTemplate,omitempty"`
}

type Store

type Store interface {
	Save(ctx context.Context, settings *Settings) error
	GetByDAGName(ctx context.Context, dagName string) (*Settings, error)
	List(ctx context.Context) ([]*Settings, error)
	DeleteByDAGName(ctx context.Context, dagName string) error
	SaveWorkspaceSettings(ctx context.Context, settings *WorkspaceSettings) error
	GetWorkspaceSettings(ctx context.Context) (*WorkspaceSettings, error)
	SaveRouteSet(ctx context.Context, routeSet *RouteSet) error
	GetRouteSet(ctx context.Context, scope RouteScope, workspace string) (*RouteSet, error)
	ListRouteSets(ctx context.Context) ([]*RouteSet, error)
	DeleteRouteSet(ctx context.Context, scope RouteScope, workspace string) error
	SaveChannel(ctx context.Context, channel *Channel) error
	GetChannel(ctx context.Context, channelID string) (*Channel, error)
	ListChannels(ctx context.Context) ([]*Channel, error)
	DeleteChannel(ctx context.Context, channelID string) error
}

type Subscription

type Subscription struct {
	ID        string                 `json:"id"`
	ChannelID string                 `json:"channelId"`
	Enabled   bool                   `json:"enabled"`
	Events    []eventstore.EventType `json:"events,omitempty"`
}

func (Subscription) ToPublic

func (s Subscription) ToPublic() PublicSubscription

type Target

type Target struct {
	ID      string                 `json:"id"`
	Name    string                 `json:"name,omitempty"`
	Type    ProviderType           `json:"type"`
	Enabled bool                   `json:"enabled"`
	Events  []eventstore.EventType `json:"events,omitempty"`

	Email    *EmailTarget    `json:"email,omitempty"`
	Webhook  *WebhookTarget  `json:"webhook,omitempty"`
	Slack    *SlackTarget    `json:"slack,omitempty"`
	Telegram *TelegramTarget `json:"telegram,omitempty"`
}

func (Target) ToPublic

func (t Target) ToPublic() PublicTarget

type TelegramTarget

type TelegramTarget struct {
	BotToken        string `json:"botToken,omitempty"`
	ChatID          string `json:"chatId,omitempty"`
	TopicID         string `json:"topicId,omitempty"`
	MessageTemplate string `json:"messageTemplate,omitempty"`
}

type WebhookTarget

type WebhookTarget struct {
	URL                 string            `json:"url,omitempty"`
	Headers             map[string]string `json:"headers,omitempty"`
	HMACSecret          string            `json:"hmacSecret,omitempty"`
	MessageTemplate     string            `json:"messageTemplate,omitempty"`
	AllowInsecureHTTP   bool              `json:"allowInsecureHttp,omitempty"`
	AllowPrivateNetwork bool              `json:"allowPrivateNetwork,omitempty"`
	ClearHeaders        bool              `json:"-"`
	ClearHMACSecret     bool              `json:"-"`
}

type WorkspaceSettings

type WorkspaceSettings struct {
	SMTP *SMTPConfig `json:"smtp,omitempty"`

	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	UpdatedBy string    `json:"updatedBy,omitempty"`
}

func NormalizeWorkspaceSettings

func NormalizeWorkspaceSettings(settings *WorkspaceSettings, updatedBy string) (*WorkspaceSettings, error)

func (WorkspaceSettings) ToPublic

Jump to

Keyboard shortcuts

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