notifications

package
v0.7.539 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 10 Imported by: 0

Documentation

Overview

Package notifications encapsulates how a notification reaches a user. Feature code depends only on the Notifier interface; the concrete Service fans each notification out to a set of delivery Channels (in-app store, email, and any future medium) that it treats agnostically.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptySMTPHost  = errors.New("mailer: empty smtp host")
	ErrEmptyRecipient = errors.New("mailer: empty recipient")
)

Functions

This section is empty.

Types

type Channel

type Channel interface {
	Deliver(n domain.Notification) error
}

Channel delivers a notification through one medium. A new delivery method is added by implementing Channel and registering it with a Service — nothing else in the system changes.

type EmailChannel

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

EmailChannel emails a notification to the owner when their settings opt in for that notification type. Delivery is asynchronous and best-effort: emailing must never block or fail the in-app notification path.

func NewEmailChannel

func NewEmailChannel(settings SettingsProvider, sender Sender) *EmailChannel

func (*EmailChannel) Deliver

func (c *EmailChannel) Deliver(n domain.Notification) error

type Notifier

type Notifier interface {
	Add(n domain.Notification) error
}

Notifier records a notification. Feature code (handlers, repos) depends on this and nothing else about how notifications are delivered.

type SMTPMailer

type SMTPMailer struct{}

SMTPMailer sends email over the user's own SMTP server. It is the default Sender used by EmailChannel.

func NewSMTPMailer

func NewSMTPMailer() *SMTPMailer

func (*SMTPMailer) Send

func (m *SMTPMailer) Send(cfg domain.NotificationSettings, subject, body string) error

type Sender

type Sender interface {
	Send(cfg domain.NotificationSettings, subject, body string) error
}

Sender delivers a single email using caller-supplied SMTP settings.

type Service

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

Service fans a notification out to every registered Channel.

func New

func New(channels ...Channel) *Service

func (*Service) Add

func (s *Service) Add(n domain.Notification) error

Add delivers the notification to every channel, returning their joined errors. A failing channel never blocks the others, and callers treat notification errors as non-fatal (log-and-continue).

type SettingsProvider

type SettingsProvider interface {
	GetNotificationSettings(userId string) (domain.NotificationSettings, error)
}

SettingsProvider resolves a user's notification settings.

type Store

type Store interface {
	Add(n domain.Notification) error
}

Store persists notifications for the in-app feed.

type StoreChannel

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

StoreChannel is the in-app delivery channel: it persists the notification so the UI can read it back. Delivery is synchronous — its error is the one callers care about.

func NewStoreChannel

func NewStoreChannel(store Store) *StoreChannel

func (*StoreChannel) Deliver

func (c *StoreChannel) Deliver(n domain.Notification) error

Jump to

Keyboard shortcuts

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