util

package
v0.0.0-...-fc1d423 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger *zap.Logger

Functions

func GetKramerism

func GetKramerism() string

Function to randomly select a kramerism

func SendPostRequest

func SendPostRequest(url string, jsonBody []byte)

Send a post request to the webhook

func SetupLogger

func SetupLogger(logLevel zapcore.Level, fileMode bool) *zap.Logger

function to setup the logger

func ShortenString

func ShortenString(str string, length int) string

Function to shorten a string to specified length

func ValidateConfig

func ValidateConfig(config *Config) error

ValidateConfig validates the configuration

Types

type APIConfig

type APIConfig struct {
	Enabled         bool     `mapstructure:"enabled"`
	Port            int      `mapstructure:"port"`
	WebURL          string   `mapstructure:"web_url"`
	CORSOrigins     []string `mapstructure:"cors_origins"`
	JWTExpiryHours  int      `mapstructure:"jwt_expiry_hours"`
	SummaryTimezone string   `mapstructure:"summary_timezone"`
}

APIConfig holds configuration for the HTTP API server.

type AmazonConfig

type AmazonConfig struct {
	ScrapeInterval  int      `mapstructure:"scrape_interval"`
	MaxStoredDeals  int      `mapstructure:"max_stored_deals"`
	URLs            []string `mapstructure:"urls"`
	TargetPriceDrop int      `mapstructure:"target_price_drop"`
}

AmazonConfig holds Amazon scraper configuration

type Config

type Config struct {
	LogLevel  int  `mapstructure:"log_level"`
	LogToFile bool `mapstructure:"log_to_file"`
	TestMode  bool `mapstructure:"test_mode"`
	SQLite    SQLiteConfig
	Scrapers  ScrapersConfig
	Pipup     PipupConfig
	API       APIConfig
	SMTP      SMTPConfig
}

Config holds the application configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config with default values

func SetupConfig

func SetupConfig(confPath string, logger *zap.Logger) (*Config, error)

SetupConfig initializes and validates the configuration

type EmailService

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

EmailService sends transactional emails via SMTP (STARTTLS, port 587). If Host or Username is empty, Send is a no-op (graceful degradation for self-hosted deployments without an SMTP server configured).

func NewEmailService

func NewEmailService(cfg SMTPConfig) *EmailService

NewEmailService creates an EmailService from the provided config.

func (*EmailService) Enabled

func (s *EmailService) Enabled() bool

Enabled reports whether SMTP is configured (Host is sufficient; auth is optional).

func (*EmailService) Send

func (s *EmailService) Send(to, subject, htmlBody string) error

Send delivers an HTML email. Returns nil without sending if SMTP is not configured. When Username is empty, authentication is skipped (suitable for unauthenticated local SMTP relays).

func (*EmailService) SendDailySummary

func (s *EmailService) SendDailySummary(to string, ozbDeals []models.OzBargainDeal, amzDeals []models.CamCamCamDeal) error

SendDailySummary sends the nightly deal digest email. ozbDeals should be pre-filtered to OZB_SUPER type, sorted by votes descending. amzDeals should be pre-filtered to AMZ_DAILY type.

func (*EmailService) SendPasswordResetEmail

func (s *EmailService) SendPasswordResetEmail(to, resetLink string) error

SendPasswordResetEmail sends the password reset email.

func (*EmailService) SendVerificationEmail

func (s *EmailService) SendVerificationEmail(to, verifyLink string) error

SendVerificationEmail sends the account verification email.

type OzBargainConfig

type OzBargainConfig struct {
	ScrapeInterval int `mapstructure:"scrape_interval"`
	MaxStoredDeals int `mapstructure:"max_stored_deals"`
}

OzBargainConfig holds OzBargain scraper configuration

type PipupConfig

type PipupConfig struct {
	Enabled         bool   `mapstructure:"enabled"`
	Username        string `mapstructure:"username"`
	BaseURL         string `mapstructure:"base_url"`
	Duration        int    `mapstructure:"duration"`
	MediaType       string `mapstructure:"media_type"`
	MediaURI        string `mapstructure:"media_uri"`
	ImageWidth      int    `mapstructure:"image_width"`
	Position        int    `mapstructure:"position"`
	TitleColor      string `mapstructure:"title_color"`
	TitleSize       int    `mapstructure:"title_size"`
	MessageColor    string `mapstructure:"message_color"`
	MessageSize     int    `mapstructure:"message_size"`
	BackgroundColor string `mapstructure:"background_color"`
}

PipupConfig holds Android TV notification configuration

type RssParser

type RssParser struct {
	Url    string
	Logger *zap.Logger
}

func (*RssParser) ParseFeed

func (rss *RssParser) ParseFeed() (*gofeed.Feed, error)

Parse the RSS Url and return feed item

func (*RssParser) SetUrl

func (rss *RssParser) SetUrl(url string)

Change Url

type SMTPConfig

type SMTPConfig struct {
	Host     string `mapstructure:"host"`
	Port     int    `mapstructure:"port"`
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
	From     string `mapstructure:"from"`
}

SMTPConfig holds outbound email (STARTTLS) configuration.

type SQLiteConfig

type SQLiteConfig struct {
	DBPath string `mapstructure:"db_path"`
}

SQLiteConfig holds SQLite database configuration

type ScrapersConfig

type ScrapersConfig struct {
	OzBargain OzBargainConfig `mapstructure:"ozbargain"`
	Amazon    AmazonConfig    `mapstructure:"amazon"`
}

ScrapersConfig holds configuration for all scrapers

Jump to

Keyboard shortcuts

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