Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
From: Michael Stapelberg <michael+sup@stapelberg.de>
To: sup-devel@rubyforge.org
Subject: [sup-devel] Fwd: [PATCH] prefer To and Cc adresses of accounts on reply
Date: Thu, 07 Oct 2010 11:32:11 +0200	[thread overview]
Message-ID: <1286443847-sup-5609@midna.zekjur.net> (raw)

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

             reply	other threads:[~2010-10-07  9:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-07  9:32 Michael Stapelberg [this message]
2010-10-07 17:32 ` Rich Lane

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1286443847-sup-5609@midna.zekjur.net \
    --to=michael+sup@stapelberg.de \
    --cc=sup-devel@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox