satellite/mailservice: move logging to send rendered async to cover template parsing (#3654)
This commit is contained in:
parent
18a5e614d9
commit
7e9b633dde
@ -99,7 +99,22 @@ func (service *Service) SendRenderedAsync(ctx context.Context, to []post.Address
|
||||
service.sending.Add(1)
|
||||
go func() {
|
||||
defer service.sending.Done()
|
||||
_ = service.SendRendered(ctx, to, msg)
|
||||
|
||||
err := service.SendRendered(ctx, to, msg)
|
||||
|
||||
var recipients []string
|
||||
for _, recipient := range to {
|
||||
recipients = append(recipients, recipient.String())
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
service.log.Error("fail sending email",
|
||||
zap.Strings("recipients", recipients),
|
||||
zap.Error(err))
|
||||
} else {
|
||||
service.log.Info("email sent successfully",
|
||||
zap.Strings("recipients", recipients))
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
@ -132,22 +147,5 @@ func (service *Service) SendRendered(ctx context.Context, to []post.Address, msg
|
||||
},
|
||||
}
|
||||
|
||||
err = service.sender.SendEmail(ctx, m)
|
||||
|
||||
// log error
|
||||
var recipients []string
|
||||
for _, recipient := range to {
|
||||
recipients = append(recipients, recipient.String())
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
service.log.Error("fail sending email",
|
||||
zap.Strings("recipients", recipients),
|
||||
zap.Error(err))
|
||||
} else {
|
||||
service.log.Info("email sent successfully",
|
||||
zap.Strings("recipients", recipients))
|
||||
}
|
||||
|
||||
return err
|
||||
return service.sender.SendEmail(ctx, m)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user