infrastructure

package
v4.21.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(path string, wordsPerMinute float64, resolveSlug func(string) string) *gorm.DB

resolveSlug maps a legacy document path (file ID) to its slug; required when upgrading an older database that stored paths. Pass nil for tests or fresh databases (no path-based tables).

func FillSlugsFromPaths added in v4.21.0

func FillSlugsFromPaths(db *gorm.DB, resolveSlug func(path string) string)

FillSlugsFromPaths updates empty slug fields in highlights and readings tables by resolving each path (document ID) to its slug via the given resolver. resolveSlug should return the document slug for a given path, or empty string if not found. For highlights, only runs if the table still has a path column (pre-migration).

func MigrateHighlightsToSlugPK added in v4.21.0

func MigrateHighlightsToSlugPK(db *gorm.DB)

MigrateHighlightsToSlugPK migrates the highlights table from (user_id, path) to (user_id, slug) primary key. Run after FillSlugsFromPaths so slugs are populated. No-op if the table has already been migrated.

func MigrateReadingsToSlugPK added in v4.21.0

func MigrateReadingsToSlugPK(db *gorm.DB)

MigrateReadingsToSlugPK migrates the readings table from (user_id, path) to (user_id, slug) primary key. Run after FillSlugsFromPaths so slugs are populated. No-op if the table has already been migrated.

func TemplateEngine

func TemplateEngine(viewsFS fs.FS, translator i18n.Translator) (*html.Engine, error)

Types

type NoEmail

type NoEmail struct {
}

func (*NoEmail) From

func (s *NoEmail) From() string

func (*NoEmail) Send

func (s *NoEmail) Send(address, subject, body string) error

func (*NoEmail) SendBCC added in v4.19.0

func (s *NoEmail) SendBCC(addresses []string, subject, body string) error

func (*NoEmail) SendDocument

func (s *NoEmail) SendDocument(address, subject string, file []byte, fileName string) error

type SMTP

type SMTP struct {
	Server   string
	Port     int
	User     string
	Password string
}

func (*SMTP) From

func (s *SMTP) From() string

func (*SMTP) Send

func (s *SMTP) Send(address, subject, body string) error

func (*SMTP) SendBCC added in v4.19.0

func (s *SMTP) SendBCC(addresses []string, subject, body string) error

func (*SMTP) SendDocument

func (s *SMTP) SendDocument(address, subject string, file []byte, fileName string) error

SendDocument sends an email with the given file attached to the chosen address.

type SMTPMock

type SMTPMock struct {
	Wg       sync.WaitGroup
	LastBody string
	// contains filtered or unexported fields
}

func (*SMTPMock) CalledSend

func (s *SMTPMock) CalledSend() bool

func (*SMTPMock) From

func (s *SMTPMock) From() string

func (*SMTPMock) Send

func (s *SMTPMock) Send(address, subject, body string) error

func (*SMTPMock) SendBCC added in v4.19.0

func (s *SMTPMock) SendBCC(addresses []string, subject, body string) error

func (*SMTPMock) SendDocument

func (s *SMTPMock) SendDocument(address, subject string, file []byte, fileName string) error

Jump to

Keyboard shortcuts

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