notifysource

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package notifysource defines the interface and types for external notification sources (Gmail, Discord, etc.) that can be polled for new items.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ID              string            `json:"id"`
	Type            string            `json:"type"`
	Enabled         bool              `json:"enabled"`
	IntervalMinutes int               `json:"intervalMinutes"`
	Query           string            `json:"query,omitempty"`
	Options         map[string]string `json:"options,omitempty"`
}

Config holds the configuration for a notification source instance.

type Factory

type Factory func(cfg Config, tokens TokenAccessor) (Source, error)

Factory creates a Source from configuration and a token accessor.

type Notification

type Notification struct {
	Title      string            `json:"title"`
	Body       string            `json:"body"`
	ReceivedAt time.Time         `json:"receivedAt"`
	Meta       map[string]string `json:"meta,omitempty"`
}

Notification represents a single notification item from an external source.

type PollResult

type PollResult struct {
	Items  []Notification
	Cursor string // opaque cursor for next poll (e.g., Gmail historyId)
}

PollResult contains the result of a polling operation.

type Source

type Source interface {
	// Type returns the source type identifier (e.g., "gmail", "discord").
	Type() string

	// Poll checks for new items since the given cursor.
	// An empty cursor means first poll (source should return recent items).
	Poll(ctx context.Context, cursor string) (*PollResult, error)

	// Validate checks if credentials and configuration are valid.
	Validate(ctx context.Context) error
}

Source is the interface that notification source implementations must satisfy.

type TokenAccessor

type TokenAccessor interface {
	GetToken(key string) (string, error)
	SetToken(key, value string, expiresAt time.Time) error
	GetTokenExpiry(key string) (string, time.Time, error)
}

TokenAccessor provides read/write access to encrypted tokens for a source.

Directories

Path Synopsis
Package gmail implements a Gmail notification source using the Gmail API.
Package gmail implements a Gmail notification source using the Gmail API.

Jump to

Keyboard shortcuts

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