notifydelivery

package
v1.103.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package notifydelivery assembles the email-notification substrate (pkg/notification) into one startable handle: the settings, preference, and queue stores, the trigger-side enqueuer, and the send worker with its LISTEN/NOTIFY wakeup adapter.

The package must not import pkg/platform. The composition root (the HTTP server, which owns the portal and admin surfaces the feature serves) passes in the *sql.DB, DSN, encryptor, and branding values it already holds, and brackets Start/Stop around its serve loop.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DB is the shared platform database pool. Required.
	DB *sql.DB
	// DSN is the raw database DSN for the LISTEN connection. Empty disables
	// LISTEN/NOTIFY; the worker degrades to poll-only.
	DSN string
	// Encryptor protects the SMTP password at rest. Required (may be a
	// nil-wrapping passthrough when encryption is disabled).
	Encryptor notification.StringEncryptor
	// Branding is the deployment identity emails render with.
	Branding notification.Branding
	// DigestHourUTC is the UTC hour daily digests are scheduled for.
	DigestHourUTC int
}

Config carries everything the substrate needs. No platform types.

type Handle

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

Handle owns the running substrate.

func New

func New(cfg Config) (*Handle, error)

New composes the substrate. Returns nil when cfg.DB is nil (no database: the feature is unavailable and every accessor degrades gracefully).

func (*Handle) Enqueuer

func (h *Handle) Enqueuer() *notification.Enqueuer

Enqueuer returns the trigger-side entry point. Nil-safe: a nil handle returns a nil enqueuer, whose Notify drops everything.

func (*Handle) PortalNotifier

func (h *Handle) PortalNotifier(stores PortalStores, baseURL string) *PortalNotifier

PortalNotifier builds the portal-facing notifier over this handle's enqueuer. Returns nil when the handle is nil (feature unavailable); the caller must then leave the portal's Notifier dependency unset.

func (*Handle) Prefs

func (h *Handle) Prefs() notification.PrefsStore

Prefs returns the preference store, or nil when the feature is unavailable.

func (*Handle) SendTest

func (h *Handle) SendTest(ctx context.Context, to string) error

SendTest delivers a test email to the given recipient using the currently stored SMTP settings, so an admin can verify the configuration end to end.

func (*Handle) Settings

func (h *Handle) Settings() notification.SettingsStore

Settings returns the settings store, or nil when the feature is unavailable.

func (*Handle) Start

func (h *Handle) Start(ctx context.Context)

Start launches the send worker and, when configured, the LISTEN adapter. A LISTEN failure (e.g. missing privilege) degrades to poll-only delivery rather than failing startup. Nil-safe.

func (*Handle) Stop

func (h *Handle) Stop()

Stop shuts down the listener, worker, and enqueuer limiter, waiting for in-flight sends. Nil-safe and idempotent.

type PortalNotifier

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

PortalNotifier implements portal.Notifier: it turns portal share and thread events into queued email notifications. All failures are logged, never surfaced -- a share or comment must succeed regardless of notification state.

func NewPortalNotifier

func NewPortalNotifier(enq *notification.Enqueuer, stores PortalStores, baseURL string) *PortalNotifier

NewPortalNotifier builds a notifier over an enqueuer directly; tests and the handle-based constructor below share it.

func (*PortalNotifier) NotifyShare

func (n *PortalNotifier) NotifyShare(ctx context.Context, share *portal.Share, kind, itemID, itemTitle string)

NotifyShare queues a "shared with you" email for a direct share. Token-only shares (no recipient email) queue nothing: a share targeted by user ID alone carries no email address anywhere in the system.

func (*PortalNotifier) NotifyThreadEvent

func (n *PortalNotifier) NotifyThreadEvent(ctx context.Context, thread *portal.Thread, actorEmail, body string)

NotifyThreadEvent queues a "new comment/feedback" email for the owner of the thread's target and, on replies, the thread author, excluding the actor.

type PortalStores

type PortalStores struct {
	Assets         portal.AssetStore
	Collections    portal.CollectionStore
	Prompts        portal.PromptStore
	KnowledgePages knowledgepage.Store
}

PortalStores bundles the read access the notifier needs to resolve a thread's target (title, deep link, owner email).

Jump to

Keyboard shortcuts

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