notifications

package
v0.6.2 Latest Latest
Warning

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

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

Documentation

Overview

Package notifications provides notification context and delivery management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyBranding added in v0.5.0

func ApplyBranding(base string, baseIsHTML bool, identity *QueueIdentity, ctx *RenderContext) string

ApplyBranding stitches salutation and signature around the base body and expands placeholders.

func DefaultFallbacks added in v0.5.0

func DefaultFallbacks(cfg *config.EmailConfig) (string, string)

DefaultFallbacks returns sane defaults derived from the email config.

func DomainFromAddress added in v0.5.0

func DomainFromAddress(address string) string

DomainFromAddress extracts the domain portion of an email address.

func EnvelopeAddress added in v0.5.0

func EnvelopeAddress(identity *QueueIdentity, fallback string) string

EnvelopeAddress picks the SMTP MAIL FROM value with fallback.

func HeaderAddress added in v0.5.0

func HeaderAddress(identity *QueueIdentity, fallback string) string

HeaderAddress builds the From header with display name when present.

func SendEmail added in v0.5.0

func SendEmail(to, subject, body string) error

SendEmail is a convenience function for sending simple text emails.

func SetEmailProvider added in v0.5.0

func SetEmailProvider(p EmailProvider)

SetEmailProvider sets the global email provider.

Types

type EmailBranding added in v0.5.0

type EmailBranding struct {
	EnvelopeFrom string
	HeaderFrom   string
	Body         string
	Domain       string
}

EmailBranding bundles outbound email metadata for queue-based messages.

func PrepareQueueEmail added in v0.5.0

func PrepareQueueEmail(ctx context.Context, db *sql.DB, queueID int, baseBody string, baseIsHTML bool, cfg *config.EmailConfig, renderCtx *RenderContext) (*EmailBranding, error)

PrepareQueueEmail injects queue identity details into the outgoing body and headers.

type EmailMessage added in v0.5.0

type EmailMessage struct {
	To      []string
	Subject string
	Body    string
	HTML    bool
}

type EmailProvider added in v0.5.0

type EmailProvider interface {
	Send(ctx context.Context, msg EmailMessage) error
}

func GetEmailProvider added in v0.5.0

func GetEmailProvider() EmailProvider

GetEmailProvider returns the global email provider.

func NewSMTPProvider added in v0.5.0

func NewSMTPProvider(cfg *config.EmailConfig) EmailProvider

type Hub

type Hub interface {
	Dispatch(ctx context.Context, recipients []int, reminder PendingReminder) error
	Consume(userID int) []PendingReminder
}

func GetHub

func GetHub() Hub

GetHub returns the shared hub instance.

func NewMemoryHub

func NewMemoryHub() Hub

func SetHub

func SetHub(h Hub) Hub

SetHub replaces the shared hub instance and returns the previous hub.

type PendingReminder

type PendingReminder struct {
	TicketID     int
	TicketNumber string
	Title        string
	QueueID      int
	QueueName    string
	PendingUntil time.Time
	StateName    string
}

type QueueIdentity added in v0.5.0

type QueueIdentity struct {
	QueueID               int
	Email                 string
	DisplayName           string
	SalutationText        string
	SalutationContentType string
	SignatureText         string
	SignatureContentType  string
}

QueueIdentity captures outbound email metadata tied to a queue.

func ResolveQueueIdentity added in v0.5.0

func ResolveQueueIdentity(ctx context.Context, db *sql.DB, queueID int) (*QueueIdentity, error)

ResolveQueueIdentity loads queue-linked sender, salutation, and signature data.

func (*QueueIdentity) SalutationSnippet added in v0.5.0

func (qi *QueueIdentity) SalutationSnippet() *Snippet

SalutationSnippet exposes the queue salutation as a snippet when present.

func (*QueueIdentity) SignatureSnippet added in v0.5.0

func (qi *QueueIdentity) SignatureSnippet() *Snippet

SignatureSnippet exposes the queue signature as a snippet when present.

type RenderContext added in v0.5.0

type RenderContext struct {
	CustomerFullName string
	AgentFirstName   string
	AgentLastName    string
}

RenderContext carries values used to interpolate legacy placeholders.

func BuildRenderContext added in v0.5.0

func BuildRenderContext(ctx context.Context, db *sql.DB, customerLogin string, agentID int) *RenderContext

BuildRenderContext fetches agent and customer names for placeholder interpolation.

type SMTPProvider added in v0.5.0

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

func (*SMTPProvider) Send added in v0.5.0

func (s *SMTPProvider) Send(_ context.Context, msg EmailMessage) error

type Snippet added in v0.5.0

type Snippet struct {
	Text        string
	ContentType string
}

Snippet describes a reusable text block such as a salutation or signature.

Jump to

Keyboard shortcuts

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