fix(GODT-2627): Properly handle recording of message with Bcc fields

Ensure the SMTP send recorder properly handles the recording of messages
which may have the same body hash but have different recipients. E.g.:
send the same message twice to 2 different users via Bcc.

The send recorder now maintains a list of send requests and waiting for
a message to be sent is done one the oldest of the messages.
This commit is contained in:
Leander Beernaert
2023-05-16 17:37:25 +02:00
parent d6304b087a
commit 5fee2f707b
3 changed files with 84 additions and 43 deletions

View File

@ -89,7 +89,7 @@ func (user *User) sendMail(authID string, from string, to []string, r io.Reader)
}
// If we fail to send this message, we should remove the hash from the send recorder.
defer user.sendHash.removeOnFail(hash)
defer user.sendHash.removeOnFail(hash, to)
// Create a new message parser from the reader.
parser, err := parser.New(bytes.NewReader(b))
@ -162,7 +162,7 @@ func (user *User) sendMail(authID string, from string, to []string, r io.Reader)
}
// If the message was successfully sent, we can update the message ID in the record.
user.sendHash.addMessageID(hash, sent.ID)
user.sendHash.signalMessageSent(hash, sent.ID, to)
return nil
})