31 lines
715 B
Go
31 lines
715 B
Go
package sms
|
|
|
|
import (
|
|
"context"
|
|
|
|
"online-back/pkg/logging"
|
|
)
|
|
|
|
// Sender delivers an SMS. Plug your provider in by implementing this
|
|
// interface and passing it to auth.NewHandler.
|
|
type Sender interface {
|
|
Send(ctx context.Context, phone, message string) error
|
|
}
|
|
|
|
// LogSender is a stand-in used until a real SMS client is wired in.
|
|
// It logs the message (including the OTP) so local testing still works.
|
|
type LogSender struct {
|
|
logger *logging.Logger
|
|
}
|
|
|
|
func NewLogSender(logger *logging.Logger) *LogSender {
|
|
return &LogSender{logger: logger}
|
|
}
|
|
|
|
func (s *LogSender) Send(_ context.Context, phone, message string) error {
|
|
if s.logger != nil {
|
|
s.logger.Infof("sms to %s: %s", phone, message)
|
|
}
|
|
return nil
|
|
}
|