refac: fixed, better, smarter, correct dependency injection

This commit is contained in:
Florian Sylvain
2025-03-29 00:51:01 +01:00
parent d895477b8c
commit a77a5ad314
35 changed files with 169 additions and 144 deletions
@@ -4,11 +4,12 @@ import (
"GoCMS/domain/gateways"
"bytes"
"embed"
"gopkg.in/gomail.v2"
"html/template"
"log"
"os"
"strconv"
"gopkg.in/gomail.v2"
)
type MailRepository struct{}
@@ -16,7 +17,11 @@ type MailRepository struct{}
//go:embed mail/templates/*
var mailTemplateFiles embed.FS
func (m MailRepository) Send(receiverAddress string, templateName string, data interface{}) error {
func NewMailRepository() *MailRepository {
return &MailRepository{}
}
func (m MailRepository) Send(receiverAddress string, templateName string, data any) error {
from := os.Getenv("SMTP_EMAIL")
password := os.Getenv("SMTP_PASSWORD")
smtpHost := os.Getenv("SMTP_HOST")