fix(GODT-2693): Duplicate messages in sent folder

* Only call `RemoveOnFail` on error. It was also called on success.
* Add some logging to track send times.
* Fix non-deterministic hash from `rfc8222.GetMessageHash`.
    https://github.com/ProtonMail/gluon/pull/395
This commit is contained in:
Leander Beernaert
2023-08-29 12:38:13 +02:00
parent 66c30716ea
commit f7252ed40e
4 changed files with 25 additions and 6 deletions

View File

@ -22,6 +22,7 @@ import (
"errors"
"fmt"
"io"
"time"
"github.com/ProtonMail/gluon/async"
"github.com/ProtonMail/gluon/logging"
@ -254,6 +255,13 @@ type sendMailReq struct {
func (s *Service) sendMail(ctx context.Context, req *sendMailReq) error {
defer async.HandlePanic(s.panicHandler)
start := time.Now()
s.log.Debug("Received send mail request")
defer func() {
end := time.Now()
s.log.Debugf("Send mail request finished in %v", end.Sub(start))
}()
if err := s.smtpSendMail(ctx, req.authID, req.from, req.to, req.r); err != nil {
if apiErr := new(proton.APIError); errors.As(err, &apiErr) {
s.log.WithError(apiErr).WithField("Details", apiErr.DetailsToString()).Error("failed to send message")