fix(smtp): cargar config SMTP desde BD al arranque para que persista entre redeploys
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/sujit-baniya/fiber-boilerplate/pkg/models"
|
||||
"github.com/sujit-baniya/fiber-boilerplate/pkg/services"
|
||||
"github.com/sujit-baniya/fiber-boilerplate/rest/routes"
|
||||
"github.com/sujit-baniya/fiber-boilerplate/utils"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -130,6 +131,20 @@ func main() {
|
||||
migrations.SeedWebSms()
|
||||
migrations.SeedUrlMonitor()
|
||||
migrations.SeedTareas()
|
||||
// Cargar config SMTP desde BD (sobreescribe valores del .env/config.yml si hay registro activo)
|
||||
if smtpCfg, err := models.GetSmtpConfig(); err == nil {
|
||||
app.Http.Mail.Host = smtpCfg.Host
|
||||
app.Http.Mail.Port = smtpCfg.Port
|
||||
app.Http.Mail.Username = smtpCfg.Username
|
||||
app.Http.Mail.Password = utils.Decrypt(smtpCfg.Password, app.Http.Server.Key)
|
||||
app.Http.Mail.Encryption = smtpCfg.Encryption
|
||||
app.Http.Mail.FromAddress = smtpCfg.FromAddress
|
||||
app.Http.Mail.FromName = smtpCfg.FromName
|
||||
app.Http.Mail.SetupMailer()
|
||||
log.Println("[SMTP] Configuración cargada desde base de datos")
|
||||
} else {
|
||||
log.Println("[SMTP] Sin config en BD, usando valores del entorno")
|
||||
}
|
||||
// Iniciar cron de vencimientos
|
||||
services.IniciarCron()
|
||||
defer services.DetenerCron()
|
||||
|
||||
Reference in New Issue
Block a user