GODT-2002: Poll after SMTP send

After sending, a client might append to the sent folder over IMAP.
In this case, we perform deduplication and return the message ID of the
sent message. However, if we haven't already processed this message in
gluon, it doesn't work as expected.

This change polls the event stream immediately after send. Note that it
doesn't wait for these events to be processed; that should be done in a
follow-up commit.
This commit is contained in:
James Houlahan
2022-10-31 17:36:50 +01:00
parent b0f939bfaf
commit a213b48f93
4 changed files with 38 additions and 19 deletions

View File

@ -268,6 +268,8 @@ func (conn *imapConnector) CreateMessage(
if messageID, ok, err := conn.sendHash.hasEntryWait(ctx, hash, time.Now().Add(90*time.Second)); err != nil {
return imap.Message{}, nil, fmt.Errorf("failed to check send hash: %w", err)
} else if ok {
conn.log.WithField("messageID", messageID).Debug("Message already sent")
message, err := conn.client.GetMessage(ctx, messageID)
if err != nil {
return imap.Message{}, nil, fmt.Errorf("failed to fetch message: %w", err)