From 37b82db82623a76f888a361fa8077c01f3a16fba Mon Sep 17 00:00:00 2001 From: wmorgan Date: Wed, 28 Nov 2007 17:01:07 +0000 Subject: [PATCH] replymode does a better job of replying from the email address you received the mail at git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@732 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- lib/sup/modes/reply-mode.rb | 13 +++++++------ lib/sup/person.rb | 10 +++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/sup/modes/reply-mode.rb b/lib/sup/modes/reply-mode.rb index 4f1c334..8ecf837 100644 --- a/lib/sup/modes/reply-mode.rb +++ b/lib/sup/modes/reply-mode.rb @@ -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" => [], diff --git a/lib/sup/person.rb b/lib/sup/person.rb index ba27205..dba7f5f 100644 --- a/lib/sup/person.rb +++ b/lib/sup/person.rb @@ -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 -- 2.45.2