aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2009-10-28 13:09:08 -0700
committerGravatar Carl Worth <cworth@cworth.org>2009-10-28 13:09:08 -0700
commit3a91df21caddd952fe9a3e3ba8128e781a3f6ec5 (patch)
treed7226287369efbae5f048961aa9e675110ed6a84
parentf9bbd7baa07110c7f345c8413e2426d00382cb1c (diff)
index: Store "Full Name <user@example.com>" addressses in the database
We put these is as a separate term so that they can be extracted. We don't actually need this for searching, since typing an email address in as a search term will already trigger a phrase search that does exactly what's wanted.
-rw-r--r--database.cc1
-rw-r--r--index.cc20
2 files changed, 17 insertions, 4 deletions
diff --git a/database.cc b/database.cc
index 583bee82..b7fb1f10 100644
--- a/database.cc
+++ b/database.cc
@@ -106,6 +106,7 @@ prefix_t BOOLEAN_PREFIX_INTERNAL[] = {
{ "type", "T" },
{ "ref", "XREFERENCE" },
{ "timestamp", "XTIMESTAMP" },
+ { "contact", "XCONTACT" }
};
prefix_t BOOLEAN_PREFIX_EXTERNAL[] = {
diff --git a/index.cc b/index.cc
index 88634fc7..b51d2261 100644
--- a/index.cc
+++ b/index.cc
@@ -30,13 +30,23 @@ _index_address_mailbox (notmuch_message_t *message,
InternetAddress *address)
{
InternetAddressMailbox *mailbox = INTERNET_ADDRESS_MAILBOX (address);
- const char *name, *addr = internet_address_mailbox_get_addr (mailbox);
+ const char *name, *addr;
+ char *contact;
int own_name = 0;
- if (addr)
- _notmuch_message_gen_terms (message, prefix_name, addr);
-
name = internet_address_get_name (address);
+ addr = internet_address_mailbox_get_addr (mailbox);
+
+ if (addr) {
+ if (name) {
+ contact = talloc_asprintf (message, "\"%s\" <%s>",
+ name, addr);
+ _notmuch_message_add_term (message, "contact", contact);
+ talloc_free (contact);
+ } else {
+ _notmuch_message_add_term (message, "contact", addr);
+ }
+ }
/* In the absence of a name, we'll strip the part before the @
* from the address. */
@@ -52,6 +62,8 @@ _index_address_mailbox (notmuch_message_t *message,
if (name)
_notmuch_message_gen_terms (message, prefix_name, name);
+ if (addr)
+ _notmuch_message_gen_terms (message, prefix_name, addr);
}
static void