notify

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package notify defines broker approval notification interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string

Action is an approval decision action.

const (
	ActionApprove Action = "approve"
	ActionDeny    Action = "deny"
)

type ApprovalMessage

type ApprovalMessage struct {
	GrantID          string
	DecisionToken    string
	Text             string
	Client           string
	Operation        string
	Target           string
	Reason           string
	RequestedMinutes int
	MaxUses          usebudget.Limit
	Fields           []Field
}

ApprovalMessage is the generic notification payload for an approval request.

type Decision

type Decision struct {
	Action        Action
	GrantID       string
	DecisionToken string
	Approver      string
	ChatID        int64
	CallbackID    string
	MessageID     int
	MessageText   string
	OperatorID    int64
	OperatorTag   string
}

Decision is a parsed operator decision.

type DecisionResult

type DecisionResult struct {
	// Answer is the short callback answer shown by the approval channel.
	Answer string
	// Retry leaves the callback unanswered and its update offset uncommitted.
	// Brokers use it when a durable decision transaction could not be saved.
	Retry bool
}

DecisionResult is the callback answer returned after an operator decision.

type Field

type Field struct {
	Name  string
	Value string
}

Field is one provider-specific display line.

type Memory

type Memory struct {
	Messages []ApprovalMessage
	Statuses []string
}

Memory is an in-memory notifier for tests and local dry runs.

func (*Memory) SendApproval

func (m *Memory) SendApproval(_ context.Context, msg ApprovalMessage) (MessageRef, error)

SendApproval records msg and returns a fake message reference.

func (*Memory) UpdateStatus

func (m *Memory) UpdateStatus(_ context.Context, _ MessageRef, status string) error

UpdateStatus records a status update.

type MessageRef

type MessageRef struct {
	Kind      string `json:"kind"`
	ChatID    int64  `json:"chat_id"`
	MessageID int    `json:"message_id"`
	Text      string `json:"text"`
}

MessageRef identifies an editable notification.

type Notifier

type Notifier interface {
	SendApproval(context.Context, ApprovalMessage) (MessageRef, error)
	UpdateStatus(context.Context, MessageRef, string) error
}

Notifier sends approval requests and status updates.

Directories

Path Synopsis
Package telegram implements a reusable Telegram approval notifier.
Package telegram implements a reusable Telegram approval notifier.

Jump to

Keyboard shortcuts

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