Repository: thunderbird/thunderbird-android (language: kotlin)

Issue:
Problematic behavior with mailing lists
### Checklist

- [X] I have used the search function to see if someone else has already submitted the same bug report.
- [X] I will describe the problem with as much detail as possible.

### App version

6.305

### Where did you get the app from?

Other

### Android version

Android 11 custom ROM

### Device model

Crosscall Core X4

### Steps to reproduce

Hello,

When I receive an email with a mailing list (known and not local) as recipient, I have the following behavior :
**Incomplete mail :** 
_Answer :_ just mail author (label)(normal behavior)
_Answer all :_ mail author (label) + list (label)(normal behavior)
**Complete mail :**
_Answer :_ list (mail without label) (abnormal behavior)
_Answer all :_ mail author (label)+ list twice (one with label, one without) (abnormal behavior)

### Expected behavior

See steps to reproduce

### Actual behavior

See steps to reproduce

### Logs

_No response_


Discussion hints:
Hello @SvSky 
I have been trying to reproduce the issue you described ((in Samsung A32, Android 13)), but I am having difficulty doing so. I was wondering if you could provide me with more information on the scenario you experienced in order to help us resolve the issue. you say the same word in expected behavior and actual behavior.
could you attach a picture or video for this scenario?

Your assistance in this matter would be greatly appreciated.
Hello,
I'm sorry, i tried to describe as well as possible but my english is far from good.
I temporarily solved by modifying the following code :

    if (replyToAddresses.length > 0) {
        candidateAddress = replyToAddresses;
    } else if (listPostAddresses.length > 0) {
        candidateAddress = listPostAddresses;
    } else {
        candidateAddress = fromAddresses;
    }
 
by :

//    if (replyToAddresses.length > 0) {
//        candidateAddress = replyToAddresses;
//    } else if (listPostAddresses.length > 0) {
//        candidateAddress = listPostAddresses;
//    } else {
        candidateAddress = fromAddresses;
//    }

in ReplyToParser.java

I didn't want to commit because it was a really specific problem and I didn't know the reasons for the order inside "if"


I can give you the example of my case to understand what was my problem.
My secretary sent an email (to a list with all the staff) asking for medical data.
When replying from k9, we fall into the case where "listPostAddresses" is not empty (which was the case), and that sent an email (from one of the people on the list) to the whole list, instead of sending it in reply to the secretary (person in "fromAddresses")

I hope I was able to shed some light on the problem I had

Pull request: Fetch `List-Post` header when downloading partial message
`ReplyToParser` currently checks the `List-Post` header to figure out which email address to use as recipient when replying. With this change we make sure the `List-Post` header is always available, i.e. we explicitly fetch it when downloading a partial message.

Fixes #6414

Test command: ./gradlew :mail:protocols:imap:test --tests "com.fsck.k9.mail.store.imap.RealImapFolderTest"

Fix patch:
diff --git a/mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/RealImapFolder.kt b/mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/RealImapFolder.kt
index 6746d890520..26ff4103d48 100644
--- a/mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/RealImapFolder.kt
+++ b/mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/RealImapFolder.kt
@@ -543,7 +543,7 @@ internal class RealImapFolder(
             fetchFields.add("RFC822.SIZE")
             fetchFields.add(
                 "BODY.PEEK[HEADER.FIELDS (date subject from content-type to cc bcc " +
-                    "reply-to message-id references in-reply-to list-unsubscribe sender " +
+                    "reply-to message-id references in-reply-to list-post list-unsubscribe sender " +
                     K9MailLib.IDENTITY_HEADER + " " + K9MailLib.CHAT_HEADER + ")]",
             )
         }


Test patch:
diff --git a/mail/protocols/imap/src/test/java/com/fsck/k9/mail/store/imap/RealImapFolderTest.kt b/mail/protocols/imap/src/test/java/com/fsck/k9/mail/store/imap/RealImapFolderTest.kt
index 27225051ea0..c87615f2c8d 100644
--- a/mail/protocols/imap/src/test/java/com/fsck/k9/mail/store/imap/RealImapFolderTest.kt
+++ b/mail/protocols/imap/src/test/java/com/fsck/k9/mail/store/imap/RealImapFolderTest.kt
@@ -673,7 +673,7 @@ class RealImapFolderTest {
         verify(imapConnection).sendCommand(
             "UID FETCH 1 (UID INTERNALDATE RFC822.SIZE BODY.PEEK[HEADER.FIELDS " +
                 "(date subject from content-type to cc bcc reply-to message-id references in-reply-to " +
-                "list-unsubscribe sender X-K9mail-Identity Chat-Version)])",
+                "list-post list-unsubscribe sender X-K9mail-Identity Chat-Version)])",
             false,
         )
     }