Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-devel] [PATCH] prefer To and Cc adresses of accounts on reply
@ 2010-10-07  9:05 Gaudenz Steinlin
  2010-10-08  4:22 ` Rich Lane
  0 siblings, 1 reply; 3+ messages in thread
From: Gaudenz Steinlin @ 2010-10-07  9:05 UTC (permalink / raw)
  To: sup-devel


[-- Attachment #1.1: Type: text/plain, Size: 2069 bytes --]

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
--
Ever tried. Ever failed. No matter.
Try again. Fail again. Fail better.
~ Samuel Beckett ~

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 482 bytes --]

[-- Attachment #2: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [sup-devel] [PATCH] prefer To and Cc adresses of accounts on reply
  2010-10-07  9:05 [sup-devel] [PATCH] prefer To and Cc adresses of accounts on reply Gaudenz Steinlin
@ 2010-10-08  4:22 ` Rich Lane
  0 siblings, 0 replies; 3+ messages in thread
From: Rich Lane @ 2010-10-08  4:22 UTC (permalink / raw)
  To: Gaudenz Steinlin; +Cc: sup-devel

Applied to master.
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [sup-devel] [PATCH] prefer To and Cc adresses of accounts on reply
@ 2010-09-15 17:56 Gaudenz Steinlin
  0 siblings, 0 replies; 3+ messages in thread
From: Gaudenz Steinlin @ 2010-09-15 17:56 UTC (permalink / raw)
  To: sup-devel


[-- Attachment #1.1: Type: text/plain, Size: 2034 bytes --]

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
--
Ever tried. Ever failed. No matter.
Try again. Fail again. Fail better.
~ Samuel Beckett ~

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

[-- Attachment #2: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-10-08  4:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-07  9:05 [sup-devel] [PATCH] prefer To and Cc adresses of accounts on reply Gaudenz Steinlin
2010-10-08  4:22 ` Rich Lane
  -- strict thread matches above, loose matches on Subject: below --
2010-09-15 17:56 Gaudenz Steinlin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox