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

Issue:
Support search in recipient addresses
When I search my inbox for, let's say, `current@freebsd` mails with `current@freebsd.org` in CC won't show up.
With lists were cross-posting is rather common this is a bit annoying.



Discussion hints:
Please support searching recipient addresses in the "Sent" folder.
I consider this a a critical usability feature.
Thanks

Pull request: Add support for search in recipient addresses
Closes #1127

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

Fix patch:
diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt
index 5189ab58d82..ab3cee1bb85 100644
--- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt
+++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt
@@ -453,6 +453,9 @@ open class MessageList :
             val search = LocalSearch().apply {
                 isManualSearch = true
                 or(SearchCondition(SearchField.SENDER, SearchSpecification.Attribute.CONTAINS, query))
+                or(SearchCondition(SearchField.TO, SearchSpecification.Attribute.CONTAINS, query))
+                or(SearchCondition(SearchField.CC, SearchSpecification.Attribute.CONTAINS, query))
+                or(SearchCondition(SearchField.BCC, SearchSpecification.Attribute.CONTAINS, query))
                 or(SearchCondition(SearchField.SUBJECT, SearchSpecification.Attribute.CONTAINS, query))
                 or(SearchCondition(SearchField.MESSAGE_CONTENTS, SearchSpecification.Attribute.CONTAINS, query))
             }
diff --git a/mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/UidSearchCommandBuilder.java b/mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/UidSearchCommandBuilder.java
index 631986b4913..65cef9062be 100644
--- a/mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/UidSearchCommandBuilder.java
+++ b/mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/UidSearchCommandBuilder.java
@@ -50,7 +50,11 @@ private void addQueryString(StringBuilder builder) {
         if (performFullTextSearch) {
             builder.append(" TEXT ").append(encodedQuery);
         } else {
-            builder.append(" OR SUBJECT ").append(encodedQuery).append(" FROM ").append(encodedQuery);
+            builder.append(" OR OR OR OR SUBJECT ").append(encodedQuery)
+                    .append(" FROM ").append(encodedQuery)
+                    .append(" TO ").append(encodedQuery)
+                    .append(" CC ").append(encodedQuery)
+                    .append(" BCC ").append(encodedQuery);
         }
     }
 


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 c74fccfcbac..0ff0ada4a95 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
@@ -1066,7 +1066,7 @@ class RealImapFolderTest {
 
         folder.search("query", emptySet(), emptySet(), false)
 
-        assertCommandIssued("UID SEARCH OR SUBJECT \"query\" FROM \"query\"")
+        assertCommandIssued("""UID SEARCH OR OR OR OR SUBJECT "query" FROM "query" TO "query" CC "query" BCC "query"""")
     }
 
     @Test
diff --git a/mail/protocols/imap/src/test/java/com/fsck/k9/mail/store/imap/UidSearchCommandBuilderTest.java b/mail/protocols/imap/src/test/java/com/fsck/k9/mail/store/imap/UidSearchCommandBuilderTest.java
index eef6e46268e..1d78cea23d5 100644
--- a/mail/protocols/imap/src/test/java/com/fsck/k9/mail/store/imap/UidSearchCommandBuilderTest.java
+++ b/mail/protocols/imap/src/test/java/com/fsck/k9/mail/store/imap/UidSearchCommandBuilderTest.java
@@ -32,6 +32,7 @@ public void build_withoutFullTextSearch() {
                 .queryString("query")
                 .build();
 
-        assertEquals("UID SEARCH OR SUBJECT \"query\" FROM \"query\" NOT DELETED", command);
+        assertEquals("UID SEARCH OR OR OR OR SUBJECT \"query\" FROM \"query\" TO \"query\" CC \"query\"" +
+                " BCC \"query\" NOT DELETED", command);
     }
 }