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 ¶
- Variables
- func Dispatch(n *Notification) error
- func SendTUI(n *Notification)
- func TUIBroadcaster() <-chan *Notification
- type Dispatcher
- type ListFilter
- type Notification
- type Stats
- type Store
- func (s *Store) Add(n *Notification) error
- func (s *Store) Clear() error
- func (s *Store) Close() error
- func (s *Store) ComputeStats() (*Stats, error)
- func (s *Store) Count() (int, error)
- func (s *Store) CountUnread() (int, error)
- func (s *Store) DB() *bolt.DB
- func (s *Store) Dismiss(id string) error
- func (s *Store) Get(id string) (*Notification, error)
- func (s *Store) List(f ListFilter, limit int) ([]*Notification, error)
- func (s *Store) MarkRead(id string) error
- func (s *Store) MarkUnread(id string) error
- func (s *Store) Path() string
- func (s *Store) Prune(ttl time.Duration) (int, error)
- type Type
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotFound = fmt.Errorf("notifications: not found")
)
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 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 Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) Add ¶
func (s *Store) Add(n *Notification) error
func (*Store) ComputeStats ¶
func (*Store) CountUnread ¶
func (*Store) List ¶
func (s *Store) List(f ListFilter, limit int) ([]*Notification, error)
func (*Store) MarkUnread ¶
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" )