]> git.cworth.org Git - sup/commitdiff
replymode does a better job of replying from the email address you received the mail at
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Wed, 28 Nov 2007 17:01:07 +0000 (17:01 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Wed, 28 Nov 2007 17:01:07 +0000 (17:01 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@732 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/modes/reply-mode.rb
lib/sup/person.rb

index 4f1c3344c3be270bfa7c2db8d1e8dcc8a13ca78f..8ecf8377a13838b7a3d8402d8f50d013c33f3f87 100644 (file)
@@ -23,19 +23,20 @@ class ReplyMode < EditMessageMode
     ## any)
     body = reply_body_lines message
 
-    from =
+    from_email, from_acct =
       if @m.recipient_email && (a = AccountManager.account_for(@m.recipient_email))
-        a
+        [@m.recipient_email, a]
       elsif(b = (@m.to + @m.cc).find { |p| AccountManager.is_account? p })
-        b
+        [b.full_address, b]
       else
-        AccountManager.default_account
+        c = AccountManager.default_account
+        [c.full_address, c]
       end
 
     ## ignore reply-to for list messages because it's typically set to
     ## the list address, which we explicitly treat with :list
     to = @m.is_list_message? ? @m.from : (@m.replyto || @m.from)
-    cc = (@m.to + @m.cc - [from, to]).uniq
+    cc = (@m.to + @m.cc - [from_acct, to]).uniq
 
     @headers = {}
 
@@ -68,7 +69,7 @@ class ReplyMode < EditMessageMode
 
     @headers.each do |k, v|
       @headers[k] = {
-               "From" => "#{from.name} <#{from.email}>",
+               "From" => from_acct.full_address(from_email),
                "To" => [],
                "Cc" => [],
                "Bcc" => [],
index ba2720562e459a39b9cae7c0586b3fafe67e5c5f..dba7f5fd9233e3a7341fd4f11d2102966d9f1c3e 100644 (file)
@@ -114,15 +114,15 @@ class Person
 
   def mediumname; @name || @email; end
 
-  def full_address
-    if @name && @email
+  def full_address email=@email
+    if @name && email
       if @name =~ /[",@]/
-        "#{@name.inspect} <#@email>" # escape quotes
+        "#{@name.inspect} <#{email}>" # escape quotes
       else
-        "#@name <#@email>"
+        "#@name <#{email}>"
       end
     else
-      @email
+      email
     end
   end