diff --git a/internal/user/smtp.go b/internal/user/smtp.go index 5b4e75b8..f5f6d2b8 100644 --- a/internal/user/smtp.go +++ b/internal/user/smtp.go @@ -327,14 +327,10 @@ func getParentID( default: // found multiple parents, search through metadata to try to find a singular parent that // was sent by this account. - found_sent_by_us := false for _, metadata := range metadata { if metadata.Flags.Has(proton.MessageFlagSent) { - if found_sent_by_us == true { - parentID = "" - } parentID = metadata.ID - found_sent_by_us = true + break } } } diff --git a/tests/features/smtp/send/send_reply.feature b/tests/features/smtp/send/send_reply.feature index a3c17143..095b5749 100644 --- a/tests/features/smtp/send/send_reply.feature +++ b/tests/features/smtp/send/send_reply.feature @@ -150,4 +150,129 @@ Feature: SMTP send reply # User1 receive the reply.| And IMAP client "1" eventually sees the following messages in "INBOX": | from | subject | body | in-reply-to | references | reply-to | - | [user:user2]@[domain] | FW - Please Reply | Heya | | | [user:user2]@[domain] | \ No newline at end of file + | [user:user2]@[domain] | FW - Please Reply | Heya | | | [user:user2]@[domain] | + + + @long-black + Scenario: Reply with In-Reply-To matching several received ExternalID + # User1 send the initial message. + When SMTP client "1" sends the following message from "[user:user1]@[domain]" to "[user:user2]@[domain]": + """ + From: Bridge Test <[user:user1]@[domain]> + To: Internal Bridge <[user:user2]@[domain]> + Subject: Please Reply + Message-ID: + + hello + + """ + Then it succeeds + When SMTP client "1" sends the following message from "[user:user1]@[domain]" to "[user:user2]@[domain]": + """ + From: Bridge Test <[user:user1]@[domain]> + To: Internal Bridge <[user:user2]@[domain]> + Subject: Please Reply Again + Message-ID: + + hello + + """ + Then it succeeds + Then IMAP client "1" eventually sees the following messages in "Sent": + | from | to | subject | message-id | + | [user:user1]@[domain] | [user:user2]@[domain] | Please Reply | | + | [user:user1]@[domain] | [user:user2]@[domain] | Please Reply Again | | + # login user2. + And the user logs in with username "[user:user2]" and password "password" + And user "[user:user2]" connects and authenticates IMAP client "2" + And user "[user:user2]" connects and authenticates SMTP client "2" + And user "[user:user2]" finishes syncing + # User2 receive the message. + Then IMAP client "2" eventually sees the following messages in "INBOX": + | from | subject | message-id | reply-to | + | [user:user1]@[domain] | Please Reply | | [user:user1]@[domain] | + | [user:user1]@[domain] | Please Reply Again | | [user:user1]@[domain] | + # User2 reply to it. + When SMTP client "2" sends the following message from "[user:user2]@[domain]" to "[user:user1]@[domain]": + """ + From: Internal Bridge <[user:user2]@[domain]> + To: Bridge Test <[user:user1]@[domain]> + Content-Type: text/plain + Subject: FW - Please Reply + In-Reply-To: + + Heya + + """ + Then it succeeds + Then IMAP client "2" eventually sees the following messages in "Sent": + | from | to | subject | in-reply-to | references | + | [user:user2]@[domain] | [user:user1]@[domain] | FW - Please Reply | | | + # User1 receive the reply.| + And IMAP client "1" eventually sees the following messages in "INBOX": + | from | subject | body | in-reply-to | references | + | [user:user2]@[domain] | FW - Please Reply | Heya | | | + + + @long-black + Scenario: Reply with In-Reply-To matching several ExternalID but one sent by us + # User1 send the initial message. + When SMTP client "1" sends the following message from "[user:user1]@[domain]" to "[user:user2]@[domain]": + """ + From: Bridge Test <[user:user1]@[domain]> + To: Internal Bridge <[user:user2]@[domain]> + Subject: Please Reply + Message-ID: + + hello + + """ + Then it succeeds + Then IMAP client "1" eventually sees the following messages in "Sent": + | from | to | subject | message-id | + | [user:user1]@[domain] | [user:user2]@[domain] | Please Reply | | + # login user2. + And the user logs in with username "[user:user2]" and password "password" + And user "[user:user2]" connects and authenticates IMAP client "2" + And user "[user:user2]" connects and authenticates SMTP client "2" + And user "[user:user2]" finishes syncing + # User2 receive the message. + Then IMAP client "2" eventually sees the following messages in "INBOX": + | from | subject | message-id | reply-to | + | [user:user1]@[domain] | Please Reply | | [user:user1]@[domain] | + # User2 reply to it. + When SMTP client "2" sends the following message from "[user:user2]@[domain]" to "[user:user1]@[domain]": + """ + From: Internal Bridge <[user:user2]@[domain]> + To: Bridge Test <[user:user1]@[domain]> + Content-Type: text/plain + Subject: FW - Please Reply + In-Reply-To: + Message-ID: + + Heya + + """ + Then it succeeds + When SMTP client "2" sends the following message from "[user:user2]@[domain]" to "[user:user1]@[domain]": + """ + From: Internal Bridge <[user:user2]@[domain]> + To: Bridge Test <[user:user1]@[domain]> + Content-Type: text/plain + Subject: FW - Please Reply Again + In-Reply-To: + Message-ID: + + Heya + + """ + Then it succeeds + Then IMAP client "2" eventually sees the following messages in "Sent": + | from | to | subject | in-reply-to | references | + | [user:user2]@[domain] | [user:user1]@[domain] | FW - Please Reply | | | + | [user:user2]@[domain] | [user:user1]@[domain] | FW - Please Reply Again | | | + # User1 receive the reply.| + And IMAP client "1" eventually sees the following messages in "INBOX": + | from | subject | in-reply-to | references | + | [user:user2]@[domain] | FW - Please Reply | | | + | [user:user2]@[domain] | FW - Please Reply Again | | | \ No newline at end of file