digest

package
v0.51.79 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HMACSecret

func HMACSecret() string

HMACSecret returns the DIGEST_HMAC_SECRET env var. Used by the unsubscribe handler to read the secret at request time rather than caching it at startup.

func Run

func Run(ctx context.Context, db *sql.DB, cfg *Config) error

Run sends weekly digest emails to eligible tenants whose deterministic send-day matches today's day of week.

When Config.TestUsername is set, only that tenant receives a digest (day-of-week check is skipped).

func UnsubscribeToken

func UnsubscribeToken(secret, tenantID string) string

UnsubscribeToken generates an HMAC-SHA256 token for one-click unsubscribe.

func ValidateUnsubscribeToken

func ValidateUnsubscribeToken(secret, tenantID, token string) bool

ValidateUnsubscribeToken checks an unsubscribe token.

Types

type Config

type Config struct {
	ResendAPIKey string
	BaseURL      string
	HMACSecret   string

	// TestUsername restricts sending to a single tenant (by username).
	// When set, only that tenant receives the digest; all others are skipped.
	// Derived from DEVPULSE_ADMIN_USERS when DIGEST_ADMIN_ONLY is true.
	TestUsername string
}

Config holds configuration for the digest sender.

func NewConfigFromEnv

func NewConfigFromEnv() *Config

NewConfigFromEnv creates a Config from environment variables. Returns nil if any required variable (SEND_API_KEY, BASE_URL, DIGEST_HMAC_SECRET) is missing.

Jump to

Keyboard shortcuts

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