feat(mail): add MailSender port and explicit provider selection
This commit is contained in:
1 parent
e7d0d92ef9
commit
6153887eb5
26 files changed
+1253
-29
No files matched your search
@@ -0,0 +1,30 @@
|
||||
// Package disabled provides the mail transport for EMAIL_PROVIDER=disabled.
|
||||
package disabled
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"lincodex/backend/internal/port/outbound"
|
||||
)
|
||||
|
||||
// Sender sends nothing. Every valid message is reported as
|
||||
// outbound.ErrMailChannelUnavailable, never as an accepted or delivered
|
||||
// message, so a caller cannot mistake the disabled mode for a delivery.
|
||||
type Sender struct{}
|
||||
|
||||
var _ outbound.MailSender = (*Sender)(nil)
|
||||
|
||||
func NewSender() *Sender {
|
||||
return &Sender{}
|
||||
}
|
||||
|
||||
// Send validates the message first so that local runs without a transport
|
||||
// still expose invalid messages, then reports the channel as unavailable. It
|
||||
// logs nothing and keeps no copy of the recipient or the content.
|
||||
func (sender *Sender) Send(_ context.Context, mail outbound.OutgoingMail) (outbound.SendResult, error) {
|
||||
if err := mail.Validate(); err != nil {
|
||||
return outbound.SendResult{}, fmt.Errorf("Sender.Send - validate mail: %w", err)
|
||||
}
|
||||
return outbound.SendResult{}, fmt.Errorf("Sender.Send - EMAIL_PROVIDER is disabled: %w", outbound.ErrMailChannelUnavailable)
|
||||
}
|
||||
Reference in new issue
Block a user