[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sup-devel] Fwd: [PATCH] prefer To and Cc adresses of accounts on reply
Hi,
as you didn’t CC rich, I am forwarding this message again.
--- Begin forwarded message from Gaudenz Steinlin ---
From: Gaudenz Steinlin <gaudenz@soziologie.ch>
To: sup-devel <sup-devel@rubyforge.org>
Date: Thu, 07 Oct 2010 11:05:30 +0200
Subject: [sup-devel] [PATCH] prefer To and Cc adresses of accounts on reply
Resending this on Rich's request.
If a message was sent (To or Cc header) to an address which corresponds
to an account prefer this account over the account corresponding to the
address in recipient_email.
This solves the problem that the wrong reply from address is chosen on
mails which are sent to an account which is forwarded to another account.
---
lib/sup/modes/reply-mode.rb | 15 ++++++---------
1 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/lib/sup/modes/reply-mode.rb b/lib/sup/modes/reply-mode.rb
index bbac922..d80f35b 100644
--- a/lib/sup/modes/reply-mode.rb
+++ b/lib/sup/modes/reply-mode.rb
@@ -65,18 +65,15 @@ EOS
## if we have a value from a hook, use it.
from = if hook_reply_from
hook_reply_from
- ## otherwise, if the original email had an envelope-to header, try and use
- ## it, and look up the corresponding name form the list of accounts.
- ##
+ ## otherwise, try and find an account somewhere in the list of to's
+ ## and cc's and look up the corresponding name form the list of accounts.
+ ## if this does not succeed use the recipient_email (=envelope-to) instead.
## this is for the case where mail is received from a mailing lists (so the
## To: is the list id itself). if the user subscribes via a particular
## alias, we want to use that alias in the reply.
- elsif @m.recipient_email && (a = AccountManager.account_for(@m.recipient_email))
- Person.new a.name, @m.recipient_email
- ## otherwise, try and find an account somewhere in the list of to's
- ## and cc's.
- elsif(b = (@m.to + @m.cc).find { |p| AccountManager.is_account? p })
- b
+ elsif(b = (@m.to.collect {|t| t.email} + @m.cc.collect {|c| c.email} + [@m.recipient_email] ).find { |p| AccountManager.is_account_email? p })
+ a = AccountManager.account_for(b)
+ Person.new a.name, b
## if all else fails, use the default
else
AccountManager.default_account
--- End forwarded message ---
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel