inbox

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package inbox provides inbox logic for the Guardian CLI tool. It manages proposal notifications, state persistence, and OS notifications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveState

func SaveState(repoRoot string, s *State) error

SaveState writes .guardian/state.json to the repo root. It creates the .guardian/ directory if it does not exist.

func SendNotification

func SendNotification(title string, message string) error

SendNotification sends an OS notification with the given title and message.

On macOS, it tries terminal-notifier first, then falls back to osascript. On Linux, it tries notify-send. On other platforms, it is a no-op and returns nil.

Types

type InboxItem

type InboxItem struct {
	Proposal *config.Proposal
	Age      time.Duration
	IsOld    bool // true if age > 7 days
}

InboxItem represents a proposal that needs the user's vote.

func GetInbox

func GetInbox(
	proposals []*config.Proposal,
	votes map[string][]*config.Vote,
	constitution *config.Constitution,
	userEmail string,
	sinceLastCheck *time.Time,
) ([]InboxItem, error)

GetInbox returns proposals that need the given user's vote.

It filters proposals based on:

  • Status must be "proposed"
  • Not expired (if ProposalTTLDays > 0)
  • User must be an eligible voter (has a role in governance.voters)
  • User has not already voted for this proposal
  • If sinceLastCheck is provided, only proposals created after that time

The votes parameter maps proposal IDs to their votes.

type State

type State struct {
	LastInboxCheck time.Time `json:"last_inbox_check"`
}

State represents the local guardian state persisted in .guardian/state.json.

func LoadState

func LoadState(repoRoot string) (*State, error)

LoadState reads .guardian/state.json from the repo root. If the file does not exist, it returns a zero-valued State (no error).

Jump to

Keyboard shortcuts

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