sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 01609d744a2dceb52915c57c5bbf4fca5a410970
parent 51acac21a173e35cef8bc213695488cfb098c087
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date:   Wed, 25 Jul 2007 00:32:31 +0000

expand contact aliases in to: and from: fields for searches

git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@507 5c8cc53c-5e98-4d25-b20a-d8db53a31250

Diffstat:
M lib/sup/index.rb | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
@@ -359,7 +359,20 @@ EOS
 
 protected
 
-  def parse_user_query_string str; @qparser.parse str; end
+  def parse_user_query_string str
+    str2 = str.gsub(/(to|from):(\S+)/) do
+      field, name = $1, $2
+      if(p = ContactManager.person_with(name))
+        [field, p.email]
+      else
+        [field, name]
+      end.join(":")
+    end
+    
+    Redwood::log "translated #{str} to #{str2}" unless str2 == str
+    @qparser.parse str2
+  end
+
   def build_query opts
     query = Ferret::Search::BooleanQuery.new
     query.add_query opts[:qobj], :must if opts[:qobj]