satellite/mailservice: move logging to send rendered async to cover template parsing (#3654)

This commit is contained in:
Yaroslav Vorobiov 2019-11-28 12:29:48 +02:00 committed by GitHub
parent 18a5e614d9
commit 7e9b633dde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
}