[geary/wip/499-wrong-folks-contact] Ensure searching for Folks contacts by email is an exact match



commit 8b652df03c5a96f8d49abdc5b52080d6b778a910
Author: Michael Gratton <mike vee net>
Date:   Wed Jul 17 16:18:55 2019 +1000

    Ensure searching for Folks contacts by email is an exact match
    
    Folks's SimpleQuery does sub-string matching which we don't want when
    looking up via email, since we know we have the complete, full address.
    Work around by checking matches have the full email address before using
    one.
    
    See #499

 src/client/application/application-contact-store.vala | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/src/client/application/application-contact-store.vala 
b/src/client/application/application-contact-store.vala
index 56bab6b9..e50db919 100644
--- a/src/client/application/application-contact-store.vala
+++ b/src/client/application/application-contact-store.vala
@@ -251,7 +251,22 @@ public class Application.ContactStore : Geary.BaseObject {
 
         Folks.Individual? match = null;
         if (!view.individuals.is_empty) {
-            match = view.individuals.first();
+            // Folks does sub-string matching, but we really don't
+            // want that, so check all returned contacts for an exact
+            // match.
+            string normalised_address = address.normalize().casefold();
+            foreach (Folks.Individual poss in view.individuals) {
+                foreach (Folks.EmailFieldDetails email in poss.email_addresses) {
+                    if (email.value.normalize().casefold() == normalised_address) {
+                        match = view.individuals.first();
+                        break;
+                    }
+                }
+
+                if (match != null) {
+                    break;
+                }
+            }
         }
 
         try {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]