notifications

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: MIT Purpose: cobra CLI for sin-code notifications: list/read/dismiss/listen/clear/stats/prune.

SPDX-License-Identifier: MIT Purpose: Dispatch notifications to TUI channel, stderr, macOS, and webhooks.

SPDX-License-Identifier: MIT Purpose: helpers (paths, mkdir) for notifications package.

SPDX-License-Identifier: MIT Purpose: small json wrapper used by dispatch to keep import surface minimal.

SPDX-License-Identifier: MIT Purpose: notification model and store for todo events. Backed by bbolt.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = fmt.Errorf("notifications: not found")
)
View Source
var NotificationsCmd = &cobra.Command{
	Use:   "notifications",
	Short: "Manage sin-code todo notifications",
	Long: `System notifications for sin-code todo events.

  list [--unread]            List recent notifications
  read <id>                   Mark a notification as read
  unread <id>                 Mark a notification as unread
  dismiss <id>                Dismiss a notification
  listen                      Stream notifications as JSONL (Ctrl-C to stop)
  clear                       Delete all notifications
  prune [--older-than 168h]   Remove old/dismissed notifications
  stats                       Counts by type and read state`,
	SilenceUsage: true,
}

Functions

func Dispatch

func Dispatch(n *Notification) error

Dispatch is a convenience wrapper used by other packages (e.g. todo).

func SendTUI

func SendTUI(n *Notification)

SendTUI is the internal non-blocking send used by Dispatcher.

func TUIBroadcaster

func TUIBroadcaster() <-chan *Notification

TUIBroadcaster returns the channel that the TUI subscribes to.

Types

type Dispatcher

type Dispatcher struct {
	Store      *Store
	WebhookURL string
	Stderr     bool
	MacOS      bool
	HTTPClient *http.Client
}

Dispatcher delivers a notification through all enabled channels.

func NewDispatcher

func NewDispatcher(store *Store) *Dispatcher

func (*Dispatcher) Send

func (d *Dispatcher) Send(n *Notification) error

type ListFilter

type ListFilter struct {
	Type         Type
	TodoID       string
	Unread       bool
	NotDismissed bool
}

type Notification

type Notification struct {
	ID        string    `json:"id"`
	Type      Type      `json:"type"`
	TodoID    string    `json:"todo_id"`
	Title     string    `json:"title"`
	Message   string    `json:"message"`
	Actor     string    `json:"actor,omitempty"`
	Created   time.Time `json:"created"`
	Read      bool      `json:"read"`
	Dismissed bool      `json:"dismissed"`
}

func (*Notification) GetID

func (n *Notification) GetID() string

func (*Notification) GetMessage

func (n *Notification) GetMessage() string

func (*Notification) GetTitle

func (n *Notification) GetTitle() string

func (*Notification) GetType

func (n *Notification) GetType() string

type Stats

type Stats struct {
	Total  int          `json:"total"`
	Unread int          `json:"unread"`
	ByType map[Type]int `json:"by_type"`
}

type Store

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

func Open

func Open(path string) (*Store, error)

func (*Store) Add

func (s *Store) Add(n *Notification) error

func (*Store) Clear

func (s *Store) Clear() error

func (*Store) Close

func (s *Store) Close() error

func (*Store) ComputeStats

func (s *Store) ComputeStats() (*Stats, error)

func (*Store) Count

func (s *Store) Count() (int, error)

func (*Store) CountUnread

func (s *Store) CountUnread() (int, error)

func (*Store) DB

func (s *Store) DB() *bolt.DB

func (*Store) Dismiss

func (s *Store) Dismiss(id string) error

func (*Store) Get

func (s *Store) Get(id string) (*Notification, error)

func (*Store) List

func (s *Store) List(f ListFilter, limit int) ([]*Notification, error)

func (*Store) MarkRead

func (s *Store) MarkRead(id string) error

func (*Store) MarkUnread

func (s *Store) MarkUnread(id string) error

func (*Store) Path

func (s *Store) Path() string

func (*Store) Prune

func (s *Store) Prune(ttl time.Duration) (int, error)

type Type

type Type string
const (
	TypeTodoCreated   Type = "todo_created"
	TypeTodoAssigned  Type = "todo_assigned"
	TypeTodoClaimed   Type = "todo_claimed"
	TypeTodoCompleted Type = "todo_completed"
	TypeTodoCancelled Type = "todo_cancelled"
	TypeTodoBlocked   Type = "todo_blocked"
	TypeTodoUnblocked Type = "todo_unblocked"
	TypeTodoDeleted   Type = "todo_deleted"
	TypeTodoDepAdd    Type = "todo_dep_add"
	TypeTodoStale     Type = "todo_stale"
	TypeTodoOverdue   Type = "todo_overdue"
)

Jump to

Keyboard shortcuts

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