notify

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package notify delivers completed investigations to chat (Slack, Matrix).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(inv providers.Investigation) string

Format renders an Investigation as a concise markdown-ish message used by all notifiers.

Types

type Matrix

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

Matrix delivers via the Matrix client-server send API.

func NewMatrix

func NewMatrix(homeserver, roomID, token string) *Matrix

NewMatrix builds a Matrix notifier. homeserver is the base URL (e.g. https://matrix.org); roomID is like "!abc:hs"; token is an access token.

The txn counter is seeded from the wall clock (UnixNano) rather than 0 so that transaction ids keep increasing across process restarts. Homeservers dedupe by (access_token, txnId); a fresh process starting back at "runlore-1" could otherwise collide with a pre-restart id and have its message silently dropped. Caveat: a backwards wall-clock jump across a restart could still collide — an acceptable residual given the dedup window is minutes and the prior behaviour offered zero protection.

func (*Matrix) Deliver

func (m *Matrix) Deliver(ctx context.Context, inv providers.Investigation) error

Deliver sends the formatted investigation as an m.notice message. It carries both a plaintext body (the fallback Matrix renders literally) and a rich formatted_body (org.matrix.custom.html) so the message's mrkdwn renders as bold/links/code instead of leaking raw *asterisks* to Matrix clients.

type Multi

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

Multi delivers to several notifiers, best-effort: a failing notifier is logged, not propagated, so one bad sink doesn't block the others.

func NewMulti

func NewMulti(log *slog.Logger, notifiers ...providers.Notifier) *Multi

NewMulti builds a fan-out notifier.

func (*Multi) Deliver

func (m *Multi) Deliver(ctx context.Context, inv providers.Investigation) error

Deliver fans out to every notifier (best-effort: one bad sink never blocks the others), logs each failure, and returns the joined errors so the caller can tell delivery was incomplete. Returns nil when all sinks succeed.

func (*Multi) Len

func (m *Multi) Len() int

Len reports how many notifiers are configured.

type Slack

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

Slack delivers via a Slack incoming webhook.

func NewSlack

func NewSlack(webhookURL string) *Slack

NewSlack builds a Slack webhook notifier.

func (*Slack) Deliver

func (s *Slack) Deliver(ctx context.Context, inv providers.Investigation) error

Deliver posts the formatted investigation to the webhook. When an action carries an ApprovalID, it renders interactive Approve/Reject buttons (Block Kit).

type SlackBot

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

SlackBot delivers via the Slack Web API (chat.postMessage) using a bot token, for workspaces that provision a bot app instead of an incoming webhook. Unlike a webhook, chat.postMessage targets an explicit channel and returns HTTP 200 with {"ok":false,"error":...} on logical failures (e.g. not_in_channel).

func NewSlackBot

func NewSlackBot(token, channel string) *SlackBot

NewSlackBot builds a bot-token Slack notifier posting to channel (ID or name).

func (*SlackBot) Deliver

func (s *SlackBot) Deliver(ctx context.Context, inv providers.Investigation) error

Deliver posts the formatted investigation to the configured channel via chat.postMessage, surfacing both transport and Slack API (ok:false) errors.

Jump to

Keyboard shortcuts

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