mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-07 12:41:30 +00:00
ec21c9bb29
M28: ACME Renewal Information (RFC 9702) — CA-directed renewal timing with cert ID computation, directory endpoint discovery, graceful degradation for non-ARI CAs. 19 tests. M29: Email notifier wiring + scheduled certificate digest — SMTP connector bridged to service layer via NotifierAdapter, DigestService with HTML email template, 7th scheduler loop (24h), digest preview/send API endpoints and GUI card. 21 tests. M30: Production-ready Helm chart — server Deployment, PostgreSQL StatefulSet, agent DaemonSet, ConfigMaps, Secrets, Ingress, security contexts, health probes, example values for dev/prod/ACME scenarios. Also: OpenAPI spec updates, MCP tool additions, CI helm-lint job, documentation updates across 5 doc files and README. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
43 lines
1.4 KiB
Go
43 lines
1.4 KiB
Go
package email
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
// NotifierAdapter bridges the email.Connector (notifier.Connector interface) to the
|
|
// service.Notifier interface used by the notification registry. This adapter allows
|
|
// the existing email SMTP connector to be registered alongside Slack, Teams, etc.
|
|
type NotifierAdapter struct {
|
|
connector *Connector
|
|
}
|
|
|
|
// NewNotifierAdapter wraps an email.Connector to implement service.Notifier.
|
|
func NewNotifierAdapter(c *Connector) *NotifierAdapter {
|
|
return &NotifierAdapter{connector: c}
|
|
}
|
|
|
|
// Channel returns the notification channel identifier.
|
|
func (a *NotifierAdapter) Channel() string {
|
|
return "Email"
|
|
}
|
|
|
|
// Send delivers a notification via SMTP email.
|
|
// The recipient is the email address, subject is used as the email subject,
|
|
// and body is the email body content.
|
|
func (a *NotifierAdapter) Send(ctx context.Context, recipient string, subject string, body string) error {
|
|
if recipient == "" {
|
|
return fmt.Errorf("email: recipient address is required")
|
|
}
|
|
return a.connector.sendEmail(ctx, recipient, subject, body)
|
|
}
|
|
|
|
// SendHTML delivers an HTML email notification via SMTP.
|
|
// Used by the digest service for rich HTML digest emails.
|
|
func (a *NotifierAdapter) SendHTML(ctx context.Context, recipient string, subject string, htmlBody string) error {
|
|
if recipient == "" {
|
|
return fmt.Errorf("email: recipient address is required")
|
|
}
|
|
return a.connector.sendHTMLEmail(ctx, recipient, subject, htmlBody)
|
|
}
|