save metadata even if one of the recipients failed

This commit is contained in:
Aine
2023-05-31 10:57:21 +03:00
parent 9bcc2d462f
commit a6b20a75ab

View File

@@ -194,28 +194,23 @@ func (b *Bot) SendEmailReply(ctx context.Context) {
}
var queued bool
var hasErr bool
recipients := meta.Recipients
for _, to := range recipients {
queued, err = b.Sendmail(evt.ID, meta.From, to, data)
if queued {
b.log.Error("cannot send email: %v", err)
b.saveSentMetadata(ctx, queued, meta.ThreadID, recipients, eml, cfg)
hasErr = true
continue
}
if err != nil {
b.Error(ctx, evt.RoomID, "cannot send email: %v", err)
hasErr = true
continue
}
}
if !hasErr {
b.saveSentMetadata(ctx, queued, meta.ThreadID, recipients, eml, cfg)
}
}
type parentEmail struct {
MessageID string