commit:     c279eb2a9cf679731d643904c07d35bbc41d2dc7
Author:     Alex Legler <alex <AT> a3li <DOT> li>
AuthorDate: Mon Feb 23 23:54:34 2015 +0000
Commit:     Alex Legler <a3li <AT> gentoo <DOT> org>
CommitDate: Mon Feb 23 23:55:20 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/ag.git;a=commit;h=c279eb2a

Fix displayname extraction

---
 lib/utils.rb | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/lib/utils.rb b/lib/utils.rb
index b37437b..f8d546e 100644
--- a/lib/utils.rb
+++ b/lib/utils.rb
@@ -54,14 +54,10 @@ module Ag
     end
 
     def get_sender_displayname(message)
-      if message[:from].is_a? Mail::StructuredField
-        fix_encoding(message[:from].addrs.first.to_s).strip
-      else
-        if message[:from].respond_to? :addrs and display_name = 
message[:from].addrs.first.display_name
-          fix_encoding(display_name).strip
-        else
-          fix_encoding(message[:from].to_s).strip
-        end
+      begin
+        fix_encoding(message[:from].addrs.first.display_name).strip
+      rescue NoMethodError
+        fix_encoding(message[:from].to_s).strip
       end
     rescue ArgumentError
       ''

Reply via email to