]> git.cworth.org Git - sup/commitdiff
re-fix reply-to address chosing (reply to recipient was broken)
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Fri, 7 Dec 2007 18:39:50 +0000 (18:39 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Fri, 7 Dec 2007 18:39:50 +0000 (18:39 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@740 5c8cc53c-5e98-4d25-b20a-d8db53a31250

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

index 180ae4e7f8c70e6330594ffff62765426072eead..fb7bfd69d0828e4e4179c944e32cbe3d4f407ff5 100644 (file)
@@ -23,28 +23,34 @@ class ReplyMode < EditMessageMode
     ## any)
     body = reply_body_lines message
 
-    from_email, from_acct =
-      if @m.recipient_email && (a = AccountManager.account_for(@m.recipient_email))
-        [@m.recipient_email, a]
+    ## first, determine the address at which we received this email. this will
+    ## become our From: address in the reply.
+    from =
+      if @m.recipient_email && AccountManager.is_account_email?(@m.recipient_email)
+        PersonManager.person_for(@m.recipient_email)
       elsif(b = (@m.to + @m.cc).find { |p| AccountManager.is_account? p })
-        [nil, b]
+        b
       else
-        c = AccountManager.default_account
-        [nil, c]
+        AccountManager.default_account
       end
 
-    ## ignore reply-to for list messages because it's typically set to
-    ## the list address, which we explicitly treat with :list
+    ## now, determine to: and cc: addressess. we  ignore reply-to for list
+    ## messages because it's typically set to the list address, which we
+    ## explicitly treat with reply type :list
     to = @m.is_list_message? ? @m.from : (@m.replyto || @m.from)
-    cc = (@m.to + @m.cc - [from_acct, to]).uniq
 
-    @headers = {}
+    ## next, cc:
+    cc = (@m.to + @m.cc - [from, to]).uniq
+    Redwood::log "cc = (#{@m.to.inspect} + #{@m.cc.inspect} - #{[from, to].inspect}).uniq = #{cc.inspect}"
 
+    ## one potential reply type is "reply to recipient". this only happens
+    ## in certain cases:
     ## if there's no cc, then the sender is the person you want to reply
     ## to. if it's a list message, then the list address is. otherwise,
     ## the cc contains a recipient.
     useful_recipient = !(cc.empty? || @m.is_list_message?)
     
+    @headers = {}
     @headers[:recipient] = {
       "To" => cc.map { |p| p.full_address },
     } if useful_recipient
@@ -69,7 +75,7 @@ class ReplyMode < EditMessageMode
 
     @headers.each do |k, v|
       @headers[k] = {
-               "From" => from_acct.full_address(from_email),
+               "From" => from.full_address,
                "To" => [],
                "Cc" => [],
                "Bcc" => [],
index 8727b1cbcec8c27a3befe3c5a7e6e780de3c35cd..5bd15a82856095f7582f7f7c109218931d23d514 100644 (file)
@@ -114,13 +114,12 @@ class Person
 
   def mediumname; @name || @email; end
 
-  def full_address email=nil
-    email ||= @email
-    if @name && email
+  def full_address
+    if @name && @email
       if @name =~ /[",@]/
-        "#{@name.inspect} <#{email}>" # escape quotes
+        "#{@name.inspect} <#{@email}>" # escape quotes
       else
-        "#@name <#{email}>"
+        "#{@name} <#{@email}>"
       end
     else
       email