commit dd4b73e09b31024e6db7fe572229234b6acbc593
parent 2cde2aeb826cb80d94dec045fa105e2e791ef1b6
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Fri, 7 Dec 2007 18:39:50 +0000
re-fix reply-to address chosing (reply to recipient was broken)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@740 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
2 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/lib/sup/modes/reply-mode.rb b/lib/sup/modes/reply-mode.rb
@@ -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" => [],
diff --git a/lib/sup/person.rb b/lib/sup/person.rb
@@ -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