Enhance notification APIs with HTML email support, CC/BCC, and structured logging

Add comprehensive improvements across REST and gRPC APIs:
  - Add structured logging for all notification operations
  - Implement HTML email support with multipart/alternative MIME
  - Add CC and BCC recipient support for email notifications
  - Add GetNotifiers endpoint to query available notifier configurations
  - Support configurable From name in SMTP configuration
  - Auto-detect content type (text vs HTML) in notification bodies
  - Improve error handling and validation across all endpoints

  🤖 Generated with [Claude Code](https://claude.com/claude-code)

  Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-22 23:31:32 -07:00
parent 8229944149
commit 35b6c8aed3
12 changed files with 444 additions and 39 deletions
+19
View File
@@ -24,6 +24,14 @@ const (
TypeStdout NotificationType = "stdout"
)
// ContentType defines the format of the notification body
type ContentType string
const (
ContentTypeText ContentType = "text"
ContentTypeHTML ContentType = "html"
)
// NotificationStatus represents the current state of a notification
type NotificationStatus string
@@ -60,9 +68,20 @@ type Notification struct {
// Body is the main content of the notification
Body string `json:"body"`
// ContentType specifies the format of the body (text or html)
// Defaults to "text" if not specified. HTML is auto-detected if body starts with < or contains HTML tags.
ContentType ContentType `json:"content_type,omitempty"`
// Recipients contains the target addresses (email, slack channel, ntfy topic, etc.)
// For email: these are the "To" recipients
Recipients []string `json:"recipients"`
// CC contains carbon copy recipients (email only, optional)
CC []string `json:"cc,omitempty"`
// BCC contains blind carbon copy recipients (email only, optional)
BCC []string `json:"bcc,omitempty"`
// Metadata contains additional provider-specific data
Metadata map[string]interface{} `json:"metadata,omitempty"`
+15
View File
@@ -57,6 +57,9 @@ type NotificationService interface {
// GetStats returns notification statistics
GetStats(ctx context.Context) (*NotificationStats, error)
// GetNotifiers returns information about available notifiers
GetNotifiers(ctx context.Context) (*NotifiersResponse, error)
}
// NotificationStats contains statistics about notification processing
@@ -69,3 +72,15 @@ type NotificationStats struct {
ByStatus map[string]int64 `json:"by_status"`
AverageLatency float64 `json:"average_latency_ms"`
}
// NotifierInfo contains information about a configured notifier type
type NotifierInfo struct {
Type NotificationType `json:"type"`
Accounts []string `json:"accounts"`
DefaultAccount string `json:"default_account"`
}
// NotifiersResponse contains the list of available notifiers
type NotifiersResponse struct {
Notifiers []NotifierInfo `json:"notifiers"`
}