Documentation
¶
Overview ¶
Package extension implements the pending-actions queue for browser extension polling. Backend pushes "open this site" requests; extension polls every 30s, executes, acks.
Index ¶
Constants ¶
const DefaultTTL = 24 * time.Hour
DefaultTTL is the time-to-live for an action before it expires (R-EC10).
Variables ¶
This section is empty.
Functions ¶
func Ack ¶
Ack marks an action as acknowledged. Calling Ack twice on the same actionID is a no-op (idempotent) — second call returns nil so callers can retry safely.
func AutoMigrate ¶
AutoMigrate creates or updates the pending_actions table. Safe to call multiple times.
Types ¶
type PendingAction ¶
type PendingAction struct {
ID uint `gorm:"primaryKey" json:"id"`
Type PendingActionType `gorm:"size:32;not null" json:"type"`
TargetURL string `gorm:"size:1024;not null" json:"target_url"`
SiteName string `gorm:"size:64;index" json:"site_name"`
Reason string `gorm:"size:256" json:"reason"`
CreatedAt time.Time `gorm:"index" json:"created_at"`
AckedAt *time.Time `json:"acked_at,omitempty"`
ExpiresAt time.Time `gorm:"index" json:"expires_at"`
}
PendingAction is a unit of work that the backend queues for the browser extension to execute on its next poll. Cookies and credentials never appear here — only a target URL plus a human-readable reason.
func ListPending ¶
func ListPending(db *gorm.DB, sinceUnix int64) ([]PendingAction, error)
ListPending returns unacked, unexpired actions whose CreatedAt is strictly greater than sinceUnix. sinceUnix=0 means "all unacked + unexpired". Results are ordered by CreatedAt ascending so the extension processes oldest-first.
func (PendingAction) TableName ¶
func (PendingAction) TableName() string
TableName pins the GORM table name so it remains stable even if the package path changes.
type PendingActionType ¶
type PendingActionType string
PendingActionType enumerates supported action kinds for the extension.
const ( // ActionOpenTab instructs the extension to open the target URL in a // background tab so the user can refresh login / cookies. ActionOpenTab PendingActionType = "open_tab" )