notify

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package notify announces new mail on the desktop (docs/design/desktop.md, Notifications): the texts (notes.go) and, later, the D-Bus sender.

Index

Constants

View Source
const (
	ActionReply   = "reply"
	ActionArchive = "archive"
	ActionTrash   = "trash"
)

What a message's note offers besides "default" (open the message): the keys of its buttons (parity P-805).

View Source
const (
	ActionSnooze  = "snooze"
	ActionDismiss = "dismiss"
)

Reminder actions, besides "default" (open the app).

Variables

This section is empty.

Functions

func Broadcast

func Broadcast(publish func([]api.EventEnvelope)) func(ctx context.Context, accountID int64, mail []Mail) error

Broadcast announces new mail to the connected clients instead of the desktop, for a maild with no session bus (docs/specs/lodge-app.md, The web build): one transient message.announced event carrying the notes Notes makes, which each client shows itself. It returns an announcer for mailsync.Config.Announce.

func Buttons added in v0.8.0

func Buttons(m Mail) []string

Buttons are the actions a message's note offers on a desktop that shows buttons, in order: ActionReply, then ActionArchive and ActionTrash where the account has the mailbox. A group note has none.

Types

type Desktop

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

Desktop sends notifications over a session bus and runs open with the message of a clicked one (0 for a group note).

func NewDesktop

func NewDesktop(ctx context.Context, conn *dbus.Conn, log *slog.Logger, open func(messageID int64)) (*Desktop, error)

NewDesktop sends over conn and watches it for clicks until ctx ends.

func OpenDesktop

func OpenDesktop(ctx context.Context, log *slog.Logger, open func(messageID int64)) (*Desktop, error)

OpenDesktop connects to the session bus.

func (*Desktop) Announce

func (d *Desktop) Announce(ctx context.Context, accountID int64, mail []Mail) error

Announce shows the notes of one account's new mail (Notes). A group note replaces the account's previous group note.

func (*Desktop) Close

func (d *Desktop) Close() error

Close disconnects from the bus.

func (*Desktop) OnMail added in v0.8.0

func (d *Desktop) OnMail(f func(messageID int64, action string))

OnMail sets what a button of a message's notification does: action is ActionReply, ActionArchive or ActionTrash. Without it the notes have no buttons.

func (*Desktop) OnReminder

func (d *Desktop) OnReminder(f func(id, action string))

OnReminder sets what clicking a reminder's notification or one of its actions does: action is "default", ActionSnooze or ActionDismiss.

func (*Desktop) Remind

func (d *Desktop) Remind(ctx context.Context, rs []Reminder) error

Remind shows a notification per reminder, replacing one still shown for the same reminder.

func (*Desktop) Withdraw

func (d *Desktop) Withdraw(ctx context.Context, active map[string]bool) error

Withdraw closes the reminder notifications whose reminders are not in active: snoozed or dismissed elsewhere.

type Mail

type Mail struct {
	ID       int64
	FromName string
	FromAddr string
	Subject  string
	Preview  string
	// Archive and Trash: the account has the mailbox each button moves to.
	Archive bool
	Trash   bool
}

Mail is a newly arrived message to announce.

type Note

type Note struct {
	Summary   string
	Body      string
	MessageID int64 // the message it opens; 0 for a group
}

Note is one desktop notification.

func Notes

func Notes(mail []Mail) []Note

Notes turns the new mail of one sync pass into notifications: one note per message for up to three, or a single group note when four or more arrive.

type Reminder

type Reminder struct {
	ID      string // calendar.reminders' id
	Summary string // the event's title
	Body    string // its time and place
}

Reminder is what a reminder's notification shows (docs/design/pim.md, Reminders).

Jump to

Keyboard shortcuts

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