优化结构

This commit is contained in:
Yvan
2026-08-24 13:25:16 +08:00
parent 7a9a738c6a
commit 0b6b8ddf1a
72 changed files with 2475 additions and 1443 deletions
+6 -8
View File
@@ -13,18 +13,16 @@ import (
"strings"
"time"
"kra/internal/conf"
"kra/internal/config"
)
type emailRepo struct {
runtime *conf.Runtime
}
type emailRepo struct{ runtime *config.Store }
func NewEmailRepo(runtime *conf.Runtime) system.EmailRepo {
func NewEmailRepo(runtime *config.Store) system.EmailRepo {
return &emailRepo{runtime: runtime}
}
func (r *emailRepo) email() *conf.AdminBackend_Email {
func (r *emailRepo) email() *config.Email {
if r.runtime == nil {
return nil
}
@@ -47,7 +45,7 @@ func (r *emailRepo) DefaultRecipients() []string {
return []string{strings.TrimSpace(config.To)}
}
func emailEnabled(config *conf.AdminBackend_Email) bool {
func emailEnabled(config *config.Email) bool {
return config != nil && strings.TrimSpace(config.Host) != "" &&
strings.TrimSpace(config.From) != "" && strings.TrimSpace(config.Secret) != "" && config.Port > 0
}
@@ -82,7 +80,7 @@ func (r *emailRepo) Send(ctx context.Context, to []string, subject, body string)
dialer := &net.Dialer{Timeout: 10 * time.Second}
var conn net.Conn
var err error
if config.IsSsl {
if config.IsSSL {
conn, err = (&tls.Dialer{NetDialer: dialer, Config: &tls.Config{ServerName: config.Host, MinVersion: tls.VersionTLS12}}).DialContext(ctx, "tcp", address)
} else {
conn, err = dialer.DialContext(ctx, "tcp", address)