Add html_body field for multipart email notifications

Callers can now supply a plain-text Body alongside an HTML html_body;
the SMTP sender emits multipart/alternative using both verbatim instead
of auto-stripping HTML to derive the plain-text fallback. The legacy
content_type=HTML path is preserved (deprecated) for existing callers.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-06 23:59:12 -07:00
parent a35b3e6283
commit ac3ba35736
5 changed files with 42 additions and 25 deletions
+5 -1
View File
@@ -16,7 +16,8 @@ type SendNotificationRequest struct {
Priority int `json:"priority,omitempty"`
Subject string `json:"subject"`
Body string `json:"body"`
ContentType string `json:"content_type,omitempty"` // "text" or "html" - auto-detected if not specified
HTMLBody string `json:"html_body,omitempty"` // Optional HTML body for email; if set, sends multipart/alternative.
ContentType string `json:"content_type,omitempty"` // Deprecated: prefer html_body. "text" or "html".
Recipients []string `json:"recipients"`
CC []string `json:"cc,omitempty"` // Carbon copy recipients (email only)
BCC []string `json:"bcc,omitempty"` // Blind carbon copy recipients (email only)
@@ -75,6 +76,7 @@ func (r *SendNotificationRequest) ToNotification() *domain.Notification {
Status: domain.StatusPending,
Subject: r.Subject,
Body: r.Body,
HTMLBody: r.HTMLBody,
ContentType: contentType,
Recipients: r.Recipients,
CC: r.CC,
@@ -111,6 +113,7 @@ type Notification struct {
Status string `json:"status"`
Subject string `json:"subject"`
Body string `json:"body"`
HTMLBody string `json:"html_body,omitempty"`
ContentType string `json:"content_type,omitempty"`
Recipients []string `json:"recipients"`
CC []string `json:"cc,omitempty"`
@@ -134,6 +137,7 @@ func NotificationFromDomain(n *domain.Notification) Notification {
Status: string(n.Status),
Subject: n.Subject,
Body: n.Body,
HTMLBody: n.HTMLBody,
ContentType: string(n.ContentType),
Recipients: n.Recipients,
CC: n.CC,