notifications

package
v1.9.14 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

Variables

This section is empty.

Functions

func AdapterSend added in v1.9.10

func AdapterSend(ctx context.Context, adapterType string, adapterConfig json.RawMessage, msg models.NotificationMessage) error

AdapterSend is the outbox's registered sender: one attempt through the channel adapter built from the persisted config snapshot.

func ClearRuleState added in v1.8.1

func ClearRuleState(ruleId int)

func MaskPhoneNumber added in v1.9.10

func MaskPhoneNumber(number string) string

MaskPhoneNumber keeps only the last 4 digits, so a number can be shown in logs, errors and delivery records without disclosing it.

func OnCheckStateChange added in v1.9.13

func OnCheckStateChange(transition synthetics.StateTransition)

OnCheckStateChange is the synthetics notifier (synthetics.RegisterNotifier in cmd/run.go). It runs AFTER the state transaction committed and holds no transaction: dispatch opens its own, and the SQLite main DB has a single connection, so an ambient transaction here would deadlock.

func OnOutboxTerminal added in v1.9.10

func OnOutboxTerminal(row *models.OutboxDelivery, status string, errorMsg string)

OnOutboxTerminal records the fired_notifications audit row for rule deliveries once their outcome is final (fired_notifications is append-only telemetry, so it must record the final truth). Page deliveries are logged in page_notifications instead, mirrored by the drain worker.

func RegisterPageOpener added in v1.9.10

func RegisterPageOpener(opener PageOpener)

func RegisterPageResolver added in v1.9.13

func RegisterPageResolver(resolver PageResolver)

func StartEvaluator

func StartEvaluator(ctx context.Context)

func ValidateOutboundURL added in v1.9.10

func ValidateOutboundURL(raw string) error

ValidateOutboundURL rejects a destination on the server's own network, unless ALLOW_PRIVATE_NOTIFICATION_TARGETS is set. It guards self-scoped surfaces (personal contact methods); project webhook channels are deliberately not guarded. The shared implementation lives in netguard, which synthetic checks use with their own SYNTHETICS_ALLOW_PRIVATE_TARGETS switch.

Types

type Adapter

type Adapter interface {
	Type() string
	Send(ctx context.Context, msg Message) error
	Validate() error
}

func NewAdapter

func NewAdapter(channelType string, configJSON json.RawMessage) (Adapter, error)

type EmailAdapter

type EmailAdapter struct {
	Recipients []string `json:"recipients"`
}

func (*EmailAdapter) Send

func (a *EmailAdapter) Send(ctx context.Context, msg Message) error

func (*EmailAdapter) Type

func (a *EmailAdapter) Type() string

func (*EmailAdapter) Validate

func (a *EmailAdapter) Validate() error

type EvalResult

type EvalResult struct {
	Fired    bool
	Message  Message
	Messages []Message
}

type ExceptionDetails

type ExceptionDetails struct {
	Id         string
	Hash       string
	ErrorType  string
	StackTrace string
	Attributes map[string]string
	AppVersion string
	ServerName string
	RecordedAt time.Time
	TraceType  string
	TraceName  string
}

type GitHubAdapter

type GitHubAdapter struct {
	Token  string   `json:"token"`
	Owner  string   `json:"owner"`
	Repo   string   `json:"repo"`
	Labels []string `json:"labels,omitempty"`
}

func (*GitHubAdapter) Send

func (a *GitHubAdapter) Send(ctx context.Context, msg Message) error

func (*GitHubAdapter) Type

func (a *GitHubAdapter) Type() string

func (*GitHubAdapter) Validate

func (a *GitHubAdapter) Validate() error

type Message

type Message = models.NotificationMessage

type PageOpener added in v1.9.10

type PageOpener func(channelConfig json.RawMessage, rule *models.NotificationRuleWithChannel, msg Message) (opened bool, err error)

PageOpener opens an on-call page for a rule that targets an escalation channel, reporting whether a new page was opened (false = deduped into one already unresolved). It is implemented by the oncall package and registered from cmd/run.go; the indirection exists because notifications cannot import oncall (oncall imports this package for Message and the adapters).

type PageResolver added in v1.9.13

type PageResolver func(ruleId int, dedupToken string) error

PageResolver auto-resolves the unresolved page a check_down rule opened, identified by its rule-scoped dedup token. Implemented by the oncall package and registered from cmd/run.go (notifications cannot import oncall).

type PushoverAdapter added in v1.7.22

type PushoverAdapter struct {
	UserKey  string `json:"userKey"`
	AppToken string `json:"appToken"`
	Device   string `json:"device,omitempty"`
	Priority int    `json:"priority,omitempty"`
	Retry    int    `json:"retry,omitempty"`
	Expire   int    `json:"expire,omitempty"`
	Sound    string `json:"sound,omitempty"`
	TTL      int    `json:"ttl,omitempty"`
	HTML     bool   `json:"html,omitempty"`
	Callback string `json:"callback,omitempty"`
}

func (*PushoverAdapter) Send added in v1.7.22

func (a *PushoverAdapter) Send(ctx context.Context, msg Message) error

func (*PushoverAdapter) Type added in v1.7.22

func (a *PushoverAdapter) Type() string

func (*PushoverAdapter) Validate added in v1.7.22

func (a *PushoverAdapter) Validate() error

type RuleEvaluator

type RuleEvaluator func(ctx context.Context, rule *models.NotificationRule, projectId uuid.UUID) (*EvalResult, error)

type Severity

type Severity = models.NotificationSeverity

Message and Severity live in models (as NotificationMessage / NotificationSeverity) so the outbox package can persist them without importing this package; the aliases keep every call site unchanged.

type SlackAdapter

type SlackAdapter struct {
	WebhookURL string `json:"webhookUrl"`
	Channel    string `json:"channel,omitempty"`
	Username   string `json:"username,omitempty"`
}

func (*SlackAdapter) Send

func (a *SlackAdapter) Send(ctx context.Context, msg Message) error

func (*SlackAdapter) Type

func (a *SlackAdapter) Type() string

func (*SlackAdapter) Validate

func (a *SlackAdapter) Validate() error

type SmsAdapter added in v1.9.10

type SmsAdapter struct {
	PhoneNumber string `json:"phoneNumber"`
}

SmsAdapter delivers via the Twilio Messages API. Without Twilio credentials SMS is not offered at all (contact-method creation is rejected and the escalator skips SMS methods), so Send only has to fail loudly for deliveries already queued when the credentials were removed.

func (*SmsAdapter) Send added in v1.9.10

func (a *SmsAdapter) Send(ctx context.Context, msg Message) error

func (*SmsAdapter) Type added in v1.9.10

func (a *SmsAdapter) Type() string

func (*SmsAdapter) Validate added in v1.9.10

func (a *SmsAdapter) Validate() error

type TelegramAdapter added in v1.7.24

type TelegramAdapter struct {
	BotToken string `json:"botToken"`
	ChatId   string `json:"chatId"`
}

func (*TelegramAdapter) Send added in v1.7.24

func (a *TelegramAdapter) Send(ctx context.Context, msg Message) error

func (*TelegramAdapter) Type added in v1.7.24

func (a *TelegramAdapter) Type() string

func (*TelegramAdapter) Validate added in v1.7.24

func (a *TelegramAdapter) Validate() error

type WebhookAdapter

type WebhookAdapter struct {
	URL     string            `json:"url"`
	Method  string            `json:"method,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
	Secret  string            `json:"secret,omitempty"`
}

func (*WebhookAdapter) Send

func (a *WebhookAdapter) Send(ctx context.Context, msg Message) error

func (*WebhookAdapter) Type

func (a *WebhookAdapter) Type() string

func (*WebhookAdapter) Validate

func (a *WebhookAdapter) Validate() error

Jump to

Keyboard shortcuts

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