This commit is contained in:
aditya.siregar
2025-03-16 23:42:42 +07:00
parent 2554533e09
commit 214a80e5f9
3 changed files with 8 additions and 4 deletions
+5 -1
View File
@@ -3,7 +3,9 @@ package brevo
import (
"bytes"
"context"
"enaklo-pos-be/internal/common/logger"
"enaklo-pos-be/internal/entity"
"go.uber.org/zap"
"html/template"
"io/ioutil"
"log"
@@ -22,7 +24,7 @@ type ServiceImpl struct {
func (s ServiceImpl) SendEmailTransactional(ctx context.Context, param entity.SendEmailNotificationParam) error {
templateFile, err := ioutil.ReadFile(param.TemplatePath)
if err != nil {
log.Println(err)
logger.ContextLogger(ctx).Error("error when reading file template", zap.Error(err))
return err
}
@@ -91,9 +93,11 @@ func (s ServiceImpl) sendEmail(ctx context.Context, tmpl *template.Template, par
_, _, err = s.brevoConn.TransactionalEmailsApi.SendTransacEmail(ctx, payload)
if err != nil {
logger.ContextLogger(ctx).Error("error when sending email", zap.Error(err))
return err
}
logger.ContextLogger(ctx).Info("sending email success")
return nil
}