notifications

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 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

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

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

DefaultFallbacks returns sane defaults derived from the email config.

func DomainFromAddress

func DomainFromAddress(address string) string

DomainFromAddress extracts the domain portion of an email address.

func EnvelopeAddress

func EnvelopeAddress(identity *QueueIdentity, fallback string) string

EnvelopeAddress picks the SMTP MAIL FROM value with fallback.

func HeaderAddress

func HeaderAddress(identity *QueueIdentity, fallback string) string

HeaderAddress builds the From header with display name when present.

func SendEmail

func SendEmail(to, subject, body string) error

SendEmail is a convenience function for sending simple text emails.

func SetEmailProvider

func SetEmailProvider(p EmailProvider)

SetEmailProvider sets the global email provider.

Types

type EmailBranding

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

EmailBranding bundles outbound email metadata for queue-based messages.

func PrepareQueueEmail

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

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

type EmailProvider

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

func GetEmailProvider

func GetEmailProvider() EmailProvider

GetEmailProvider returns the global email provider.

func NewSMTPProvider

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

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

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

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

func (*QueueIdentity) SalutationSnippet

func (qi *QueueIdentity) SalutationSnippet() *Snippet

SalutationSnippet exposes the queue salutation as a snippet when present.

func (*QueueIdentity) SignatureSnippet

func (qi *QueueIdentity) SignatureSnippet() *Snippet

SignatureSnippet exposes the queue signature as a snippet when present.

type RenderContext

type RenderContext struct {
	CustomerFullName string
	AgentFirstName   string
	AgentLastName    string
}

RenderContext carries values used to interpolate legacy placeholders.

func BuildRenderContext

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

BuildRenderContext fetches agent and customer names for placeholder interpolation.

type SMTPProvider

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

func (*SMTPProvider) Send

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

type Snippet

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