Update notificacion_controller.go
This commit is contained in:
@@ -7,8 +7,10 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/sujit-baniya/fiber-boilerplate/app"
|
||||||
"github.com/sujit-baniya/fiber-boilerplate/pkg/models"
|
"github.com/sujit-baniya/fiber-boilerplate/pkg/models"
|
||||||
"github.com/sujit-baniya/fiber-boilerplate/pkg/services"
|
"github.com/sujit-baniya/fiber-boilerplate/pkg/services"
|
||||||
|
"github.com/sujit-baniya/fiber-boilerplate/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ─── Plantillas ─────────────────────────────────────────────────────────────
|
// ─── Plantillas ─────────────────────────────────────────────────────────────
|
||||||
@@ -135,6 +137,19 @@ func TestEnvioPlantilla(c *fiber.Ctx) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Status(404).JSON(fiber.Map{"error": "No encontrada"})
|
return c.Status(404).JSON(fiber.Map{"error": "No encontrada"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Recargar siempre la config activa desde BD antes de enviar
|
||||||
|
if cfg, err2 := models.GetSmtpConfig(); err2 == nil {
|
||||||
|
app.Http.Mail.Host = cfg.Host
|
||||||
|
app.Http.Mail.Port = cfg.Port
|
||||||
|
app.Http.Mail.Username = cfg.Username
|
||||||
|
app.Http.Mail.Password = utils.Decrypt(cfg.Password, app.Http.Server.Key)
|
||||||
|
app.Http.Mail.Encryption = cfg.Encryption
|
||||||
|
app.Http.Mail.FromAddress = cfg.FromAddress
|
||||||
|
app.Http.Mail.FromName = cfg.FromName
|
||||||
|
app.Http.Mail.SetupMailer()
|
||||||
|
}
|
||||||
|
|
||||||
if err := services.EnviarCorreoPrueba(body.Email, p); err != nil {
|
if err := services.EnviarCorreoPrueba(body.Email, p); err != nil {
|
||||||
return c.Status(500).JSON(fiber.Map{"error": err.Error()})
|
return c.Status(500).JSON(fiber.Map{"error": err.Error()})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user