Other: Properly handle SMTP to list in send recorder

Checking the BCC header is unreliable; it is usually omitted from messages.
Instead, we can use the SMTP "to" list for deduplication.
This commit is contained in:
James Houlahan
2022-10-25 16:14:56 +02:00
parent 4df8ce1b58
commit 35fa43f47c
3 changed files with 58 additions and 13 deletions

View File

@ -58,7 +58,7 @@ func (user *User) sendMail(authID string, emails []string, from string, to []str
}
// Check if we already tried to send this message recently.
if ok, err := user.sendHash.tryInsertWait(ctx, hash, time.Now().Add(90*time.Second)); err != nil {
if ok, err := user.sendHash.tryInsertWait(ctx, hash, to, time.Now().Add(90*time.Second)); err != nil {
return fmt.Errorf("failed to check send hash: %w", err)
} else if !ok {
user.log.Warn("A duplicate message was already sent recently, skipping")