Documentation
¶
Overview ¶
Package notifications provides notification context and delivery management.
Index ¶
- func ApplyBranding(base string, baseIsHTML bool, identity *QueueIdentity, ctx *RenderContext) string
- func DefaultFallbacks(cfg *config.EmailConfig) (string, string)
- func DomainFromAddress(address string) string
- func EnvelopeAddress(identity *QueueIdentity, fallback string) string
- func HeaderAddress(identity *QueueIdentity, fallback string) string
- func SendEmail(to, subject, body string) error
- func SetEmailProvider(p EmailProvider)
- type EmailBranding
- type EmailMessage
- type EmailProvider
- type Hub
- type PendingReminder
- type QueueIdentity
- type RenderContext
- type SMTPProvider
- type Snippet
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
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
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
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 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 NewMemoryHub ¶
func NewMemoryHub() Hub
type PendingReminder ¶
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
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
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