webpush

package
v0.1.1-beta.2 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PushPayload

type PushPayload struct {
	Title   string `json:"title"`
	Body    string `json:"body"`
	Session string `json:"session"`
	Window  int    `json:"window,omitempty"`
	Tool    string `json:"tool"`
	Status  string `json:"status"`
}

PushPayload is the JSON sent to the service worker

type Sender

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

Sender listens for tool events and sends push notifications

func NewSender

func NewSender(keys *VAPIDKeys, store *Store, tracker *toolevents.Tracker) *Sender

NewSender creates a push notification sender

func (*Sender) Run

func (s *Sender) Run(ctx context.Context)

Run subscribes to tool events and sends push notifications for waiting/error events

type Store

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

Store manages push notification subscriptions in memory

func NewStore

func NewStore() *Store

NewStore creates a new subscription store

func (*Store) Add

func (s *Store) Add(sub *wp.Subscription)

Add registers a push subscription

func (*Store) All

func (s *Store) All() []*wp.Subscription

All returns a snapshot of all current subscriptions

func (*Store) Count

func (s *Store) Count() int

Count returns the number of active subscriptions

func (*Store) Remove

func (s *Store) Remove(endpoint string)

Remove unregisters a push subscription by endpoint

type VAPIDKeys

type VAPIDKeys struct {
	PublicKey  string `json:"public_key"`
	PrivateKey string `json:"private_key"`
}

VAPIDKeys holds the public/private VAPID key pair

func LoadOrCreateKeys

func LoadOrCreateKeys() (*VAPIDKeys, error)

LoadOrCreateKeys loads VAPID keys from disk, or generates and persists new ones

Jump to

Keyboard shortcuts

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